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
Sangster wrote:
> 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
>
|