Hi all
I have table called "Customer Data" and it has a field called AccountNumber.This field is a Auto/Number type. Life is normal at this point.
Now I have a form with text boxes, user enters a value in text box. ( which is a accountnumber). Upon entring a account number I have the following codes which look for the account number, if account number is found then it displays customer details.
I have a acount number = 22 in the customer data table, but if enter this number my code is not returing any data. it says " Customer Not found".
Please help. Not sure why it is not seeking my account number.
Private Sub accountNumber_Exit(Cancel As Integer)
Dim res As String
Dim acnumber As Integer
Dim abc As dao.Recordset
Set abc = CurrentDb.OpenRecordset("Customer Data")
abc.Index = "PRIMARYKEY"
If IsNull(Me.accountNumber) Then
MsgBox " Account number has to be entered"
Else
acnumber = CStr(Me.accountNumber) // I tried just using acnumber, converting, etc//
abc.Seek "=", acnumber
If abc.NoMatch Then
MsgBox "Customer not found"
Else
Me.lname = abc.Fields("Customer_Last_Name")
Me.add1 = abc.Fields("Cus_Address_1")
Me.add2 = abc.Fields("Cus_Address_2")
Me.phone = abc.Fields("Cus_Tel_No")
End If
End If
End Sub
I have table called "Customer Data" and it has a field called AccountNumber.This field is a Auto/Number type. Life is normal at this point.
Now I have a form with text boxes, user enters a value in text box. ( which is a accountnumber). Upon entring a account number I have the following codes which look for the account number, if account number is found then it displays customer details.
I have a acount number = 22 in the customer data table, but if enter this number my code is not returing any data. it says " Customer Not found".
Please help. Not sure why it is not seeking my account number.
Private Sub accountNumber_Exit(Cancel As Integer)
Dim res As String
Dim acnumber As Integer
Dim abc As dao.Recordset
Set abc = CurrentDb.OpenRecordset("Customer Data")
abc.Index = "PRIMARYKEY"
If IsNull(Me.accountNumber) Then
MsgBox " Account number has to be entered"
Else
acnumber = CStr(Me.accountNumber) // I tried just using acnumber, converting, etc//
abc.Seek "=", acnumber
If abc.NoMatch Then
MsgBox "Customer not found"
Else
Me.lname = abc.Fields("Customer_Last_Name")
Me.add1 = abc.Fields("Cus_Address_1")
Me.add2 = abc.Fields("Cus_Address_2")
Me.phone = abc.Fields("Cus_Tel_No")
End If
End If
End Sub