Thread: Help with VBA in mS Access.
08-22-03, 13:36 #1Registered User
- Join Date
- Aug 2003
Unanswered: Help with VBA in mS Access.
Hi, I'm trying to put this code into a command button so when the user enters any name in a text box called txtFind the person or persons with this name will appear in the fields labeled FirstName, LastName and Address on the form called frmInfo, heres the codes I used:
Dim strSQl as String
strSQL = "SELECT * FROM tblInfo "
strSQL = strSQL & "WHERE FirstName Like ""*"
strSQL = strSQL & Forms!frmInfo.txtFind.Value
strSQL = strSQL & "*"";"
08-22-03, 14:03 #2Village Idiot
- Join Date
- Jul 2003
One way to do it is to have the form display all of the records when opened, (assuming the form is bound to the table).
In the command buttons OnClick event, put the following code:
Forms!frmInfo.Filter ="[FirstName] like ""*" & Forms!frmInfo.txtFind.Value & "*"""
Forms!frmInfo.FilterOn = True
You may have to tweak the number of " in the syntax to get it to work.
There's a different way to do it if you're using an unbound form.
In that case, you'll need the entire SQL statement you have below,
plus some more code. Let me know if this is what you're doing.
MarkInspiration Through Fermentation