Reputation: 3
I've been working for a few days on a small project that searches a table for criteria entered in four TextBoxes, using a ListBox linked to a query that finds the results. My problem is that I can search the text datatype fields just fine, but there is a field called 'Age', and I cannot find the correct criteria syntax to put in the query.
The criteria I used is this: Like "*" & [forms]![SearchTab]![schAge] & "*"
It works fine for text fields, but not for the one number field. There isn't much VBA code, just for the OnChange of the TextBox to Requery the list box like this:
Private Sub schAge_Change()
Dim SAge as Variant
SAge = schAge.Value
Me.lstResults.Requery
End Sub
Upvotes: 0
Views: 35
Reputation: 642
Are you trying to filter/search for records where some strings can be found? Then use.
Like '*" & [forms]![SearchTab]![schAge] & "*'"
Otherwise,
= " & [forms]![SearchTab]![schAge] & "
Also, since you are using Change
event, use schAge.Text
to get the last text input. schAge.Value
will only return the last value beforeUpdate of the textbox. Note: I didn't see any relation of this code from above. Where are you using SAge?
Private Sub schAge_Change()
Dim SAge as Variant
SAge = schAge.Text
Me.lstResults.Requery
End Sub
Upvotes: 1