Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    333
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Question Intermittant code failure

    I have this block of code that seems to fail about 1 in 20 times

    Code:
        Set rst3 = CurrentDb.OpenRecordset("tblItemsDD")
        For Each varItem In Me.lstList.ItemsSelected
            With rst3
                .MoveFirst
                .FindFirst "[ItemID]=" & Me.lstList.Column(0, varItem)
                If Not .NoMatch Then
                .Edit
     >>>>>  !ItemCost = InputBox("Enter per Item Cost", "Item Value") <<<<<<<
                .Update
                End If
            End With
        Next varItem
        
        Me.lstList.Requery
    The marked line normally works fine but every now and then the record refuses to update.
    If it fails the first time, it will fail consistently and I have to open the table and update the field manually to get the rest of the form code to run.
    So it seems to be record specific.

    Any thoughts would be most appreciated
    "Heading for the deep end"

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,659
    Thanks
    3
    Thanked 67 Times in 66 Posts
    Have you tried debugging the code by turning off any error handling and then looking at the various parameters to see what might be causing the error? It appears you are working with a list box or a combo box and that is often some sort of invalid value in one of the parameters, but it's difficult to tell without knowing more about your environment. Also, are you using DAO or ADO?
    Wendell

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    333
    Thanks
    10
    Thanked 0 Times in 0 Posts
    We are using DAO
    I have stepped through the code several times with problem records and it has never thrown an error
    "Heading for the deep end"

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    10,102
    Thanks
    440
    Thanked 1,637 Times in 1,477 Posts
    Could you please post your table definition for tblItemsDD.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  5. #5
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    333
    Thanks
    10
    Thanked 0 Times in 0 Posts
    table.PNG

    Is this what you want?
    "Heading for the deep end"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •