cricketbird
Registered User.
- Local time
- Yesterday, 20:36
- Joined
- Jun 17, 2013
- Messages
- 111
I currently have a button that launches a msgbox that asks "Which item?" and the user types "Fred", and it opens a report filtered to all the records where a field is
This works perfectly. However, we now want to have users be able to type in "Fred or Ginger" (or Fred and Ginger) and it should find all the records that include either like *Fred* OR like *Ginger* (or like *Fred* AND like *Ginger*).
What's the best way to go about this? I was thinking about creating a separate form with multiple text boxes, but that gets a little hairy. Does anyone have an example of allowing users to enter somewhat complex queries in a query/report record search?
Thank you!
Existing code
like *Fred*.
.This works perfectly. However, we now want to have users be able to type in "Fred or Ginger" (or Fred and Ginger) and it should find all the records that include either like *Fred* OR like *Ginger* (or like *Fred* AND like *Ginger*).
What's the best way to go about this? I was thinking about creating a separate form with multiple text boxes, but that gets a little hairy. Does anyone have an example of allowing users to enter somewhat complex queries in a query/report record search?
Thank you!
Existing code
Code:
Private Sub Command40_Click()
Dim mystr As String
mystr = InputBox("Which item?")
Dim whr As String
whr = "([ITEM] Like '*" & mystr & "*') AND [ACTIVE] = True"
DoCmd.OpenReport "RecordReport", acViewPreview, , whr, , mystr
End Sub