Form has textbox where users enter customer's account number to log transaction. DLookup function will look into tblcustomers for matching account number and return FN and LN if found. Now problem is when user enters incorrect number and want to change it or want to change customer account number after entering it first time (moved to next textbox field) access doesn't let them change the account number field without saving the record. Error is : "To make changes to this field, first save the record"
VBA for DLookup:
Code:
Private Sub TxtFirstName_GotFocus()
Dim varX As String
Dim varY As String
On Error GoTo Problem
varX = DLookup("Last_Name", "TblCustomer", "Cust_Card_No = " & [Forms]![FrmGroupLog]![Cust_Card_No])
Me.TxtFirstName = varX
varY = DLookup("First_Name", "TblCustomer", "Cust_Card_No = " & [Forms]![FrmGroupLog]![Cust_Card_No])
Me.TxtLastName = varY
Exit Sub
Problem:
If Err.Number = 94 Then
Me.TxtFirstName = " "
Me.TxtLastName = " "
MsgBox "Please Enter guest Name"
End If
End Sub