I am working on a database in Access 2010 and i have a client information table that has multiple information i have designed a form to search and display the information. The only problem i am having is the actual search.
I want to be able to search by the clients first and last name or by the account number. Currently the Account number search works perfectly when i click on the button. The major issue i have is that the name search will work for now but once i add a new client with the same name as another it will not function properly. The code is as follows for my search button:
I guess what i am looking for is a way to have the multiple solutions pop up and ask the user which one to choose.
For example if i had 3 John Doe's it would show the three clients and their phone numbers accordingly so we can select the right one to display the rest of their information.
Any suggestions?
I want to be able to search by the clients first and last name or by the account number. Currently the Account number search works perfectly when i click on the button. The major issue i have is that the name search will work for now but once i add a new client with the same name as another it will not function properly. The code is as follows for my search button:
Code:
Private Sub searchbutton_Click()
Dim first As String
Dim last As String
Dim account As String
Dim test As String
Dim test2 As String
If Not AccountTXT.Value Then
'find info with account number
first = DLookup("[First Name]", "Client Information", "[Account Number] = AccountTXT.value")
last = DLookup("[Last Name]", "Client Information", "[Account Number] = AccountTXT.value")
account = AccountTXT.Value
ElseIf Not fnameTXT.Value Then
If lnameTXT.Value = Null Then
MsgBox "Both First and Last Name are required.", vbOKOnly, "Required Info"
Else
first = fnameTXT.Value
last = lnameTXT.Value
test = DLookup("[Account Number]", "Client Information", "[Last Name] = lnameTXT.value")
test2 = DLookup("[Account Number]", "Client Information", "[First Name] = fnameTXT.value")
If test = test2 Then
account = test
Else
MsgBox "Account Number can not be found.", vbOKOnly, "ERROR"
End If
End If
Else
MsgBox "Either first and last name or account number is required.", vbOKOnly, "Required Info"
End If
For example if i had 3 John Doe's it would show the three clients and their phone numbers accordingly so we can select the right one to display the rest of their information.
Any suggestions?