swedish_mania
Registered User.
- Local time
- Today, 15:46
- Joined
- Feb 8, 2005
- Messages
- 43
Hi,
I have a form based on a table of buyers, i also have a copy of this form which includes a search button, so you can type in a surname and it displays the records above. I have got it to work, but when it finds the record it still says "Record not found for: [Surname].
I think its just a minor adjustment to the code that is need.
Once i have it i want to advance on this by instead of only allowing the user to search via surname, i want a combo box so you can search by forename, surname, postcode etc. Any suggestions will be helpful thanks.
Heres the code so far.
I have a form based on a table of buyers, i also have a copy of this form which includes a search button, so you can type in a surname and it displays the records above. I have got it to work, but when it finds the record it still says "Record not found for: [Surname].
I think its just a minor adjustment to the code that is need.
Once i have it i want to advance on this by instead of only allowing the user to search via surname, i want a combo box so you can search by forename, surname, postcode etc. Any suggestions will be helpful thanks.
Heres the code so far.
PHP:
Private Sub Search_Click()
Dim BuyerID As String
Dim strSearch As String
If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a valid Surname!", vbOKOnly, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
DoCmd.ShowAllRecords
DoCmd.GoToControl ("Surname")
DoCmd.FindRecord Me!txtSearch
Surname.SetFocus
BuyerID = Surname.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
If BuyerID = strSearch Then
MsgBox "Record Found For: " & strSearch, vbOKOnly, "Search Results."
Surname.SetFocus
txtSearch = ""
Else
MsgBox "No Records Found For: " & strSearch & " - Please Try Again.", vbOKOnly, "Invalid Search Criteria!"
txtSearch.SetFocus
End If
End Sub