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