bookmark - runtime error "3420"

S

Sangster

Me.Form.Bookmark = rst.Bookmark runs OK most of the time. But it has runtime
error 3420 from time to time. I pasted below the subroutine that causes this
problem. I would really appreciate if someone can shed light on this
mysterious problem.

Thanks,

Sang

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
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
 
S

Stefan Hoffmann

hi,
Me.Form.Bookmark = rst.Bookmark runs OK most of the time. But it has runtime
error 3420 from time to time. I pasted below the subroutine that causes this
problem.
This error normally indicates that an used object became invalid.

I would try two things:

Adding an appropriate error handling with On Error Goto and

Set rst = dbBible.OpenRecordset("tblCustomers", dbOpenSnapshot)


mfG
--> stefan <--
 
J

John Spencer

The problem is that the bookmarks for the two recordsets aren't necessarily
the same. The order of the records may be different, the number of records
may be different, etc.

Why don't you use the form's RecordSetClone?
Set rst = Me.RecordsetClone

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top