Greetings,
I have a database that is used to track all the vehicles in the company, currently over 550 vehicles. I will admit I am very new to VBA. The powers that be want to be able to search all the vehicles by the last 5 o 6 numbers in the VIN of the vehicle. I have this code right now.
The problem I am having is that if I uncomment the second if all searches come back with the message box. As the code is right now if the VIN searched for is not in the database it will display the first record in the database.
I have tried:
With this I have enter the full VIN or it comes back with the message box every time.
With this very search brings back the VIN.
Any ideas or tips on what I am missing would be great!
Thanks
When all is said and done, more is said then done. So do something
I have a database that is used to track all the vehicles in the company, currently over 550 vehicles. I will admit I am very new to VBA. The powers that be want to be able to search all the vehicles by the last 5 o 6 numbers in the VIN of the vehicle. I have this code right now.
Code:
Private Sub cmdVIN_Click()
Dim txtTest As String
If Not IsNull(Me.txtSearch) Then
txtTest = "*" & Me.txtSearch
End If
' Debug.Print txtTest
DoCmd.ShowAllRecords
DoCmd.GoToControl ("VehVIN")
DoCmd.FindRecord txtTest
' If txtTest = VehVIN Then
stDocName = "frmVehicleMod"
stLinkCriteria = "[VehVIN]=" & "'" & Me![VehVIN] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
' Else
' MsgBox "VehVIN not found."
' End If
End Sub
The problem I am having is that if I uncomment the second if all searches come back with the message box. As the code is right now if the VIN searched for is not in the database it will display the first record in the database.
I have tried:
Code:
If txtSearch = VehVIN Then
Code:
If "*" & txtSearch = VehVIN Then
Any ideas or tips on what I am missing would be great!
Thanks
When all is said and done, more is said then done. So do something