Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2008
    Posts
    2

    Unanswered: ACCESS bookmark causes runtime error 3420

    Me.Form.Bookmark = rst.Bookmark runs OK most of the times. but causing runtime error 3420 from time to time. It's myterious to me. Can anyone help me?

    Thanks,

    Sangster

    Private Sub Customer_AfterUpdate()
    Dim strCustomer As String
    Dim dbBible As DAO.Database
    Dim rst As DAO.Recordset
    Dim strCriteria As String
    Dim CustomerID As Integer

    If Not IsNothing(Me.Customer) Then
    strCustomer = Me.Customer
    CustomerID = DLookup("Customer_ID", "tblCustomers", "Customer = '" & strCustomer & "'")
    strCriteria = "Customer_ID=" & CustomerID
    Set dbBible = CurrentDb
    Set rst = dbBible.OpenRecordset("tblCustomers", dbOpenDynaset)
    rst.FindFirst strCriteria
    If rst.NoMatch Then
    MsgBox "No entry found.", vbInformation
    Else
    Me.Customer = rst!Customer
    On Error Resume Next
    Me.Form.Bookmark = rst.Bookmark
    End If
    If TempVars!frmWorkOrdersOpen = 1 Then
    Forms!frmWorkOrders.Company = rst!Customer
    Forms!frmWorkOrders.Contact = rst!Contact
    Forms!frmWorkOrders.Street = rst!Street
    Forms!frmWorkOrders.City = rst!City
    Forms!frmWorkOrders.State = rst!State
    Forms!frmWorkOrders.Zip_Code = rst!Zip_Code
    Forms!frmWorkOrders.Phone = rst!Phone
    Forms!frmWorkOrders.Refresh
    End If
    rst.Close
    Set rst = Nothing
    dbBible.Close
    Set dbBible = Nothing
    End If
    End Sub

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    I could be wrong but I think you should be using the form's RecordsetClone
    and not creating an independent recordset. Then

    Me.Form.Bookmark = rst.Bookmark

    becomes

    Me.Bookmark = Me.RecordsetClone.Bookmark

    after yoy have Me.RecordsetClone.FindFirst strCriteria

    ??

    Or, for minimum recoding, perhapse just

    Set rst = Me.RecordsetClone

    MTB

  3. #3
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    have you tried setting a breakpoint and running it until you get the error? I'd personally implement a different error handling logic to catch the error. If, instead of On Error Goto Next, you put in On Error Goto errorhandler, and then put in an errorhandler section at the bottom, where it would pop up a msgbox if err.Number = 3420, you could Ctrl-Break when you got the msgbox. Then you could see what your values were and find the problem. That make any sense, or have you already tried that?

  4. #4
    Join Date
    Aug 2008
    Posts
    2

    Thanks

    Set rst = Me.RecordsetClone worked. I appreciate your help.
    Still I don't understand the difference between RecordsetClone and OpenRecordSet.
    Thank you so much.

  5. #5
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Quote Originally Posted by skim2dbf
    Set rst = Me.RecordsetClone worked. I appreciate your help.
    Still I don't understand the difference between RecordsetClone and OpenRecordSet.
    Thank you so much.
    Hi

    Sorry for late reply but have been on hol.

    From seven or eight years ago when first looking at bookmrks etc, I seem to remember that bookmark are randomly generated for each record when the recordset is CREATED AND/OR REQUERIED. Therefore even with a given recordset (or form records) bookmark(s) for a given record change when you requery them, and bookmarks will be different for a given record between two recordset created from the same SQL stament.

    The RecordsetClone (by refinituion!) is identical to ther Form Recordset, therefore the bookmarks are the same (until you requiry the form).

    For this reason I tend to use the PK(s) to identify records

    Hope that helps (and I hope it is correct!).



    MTB

Posting Permissions

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