Filtering within search results

G_Loc

Unregistered
Local time
Today, 04:30
Joined
May 26, 2006
Messages
24
Whats the best way to filter search results?

I'll do my best to explain my problem:

I made a form that lets users search for records in a database and displays them in another form. In that form I've made 3 buttons to let users narrow down the results to show only certain items within the search results.

Now, 2 of the buttons show specific items and the third one toggles the form to display all the records. So lets say I'm filtering records by whether or not they contain the words "car" and "truck." If a record has "car" but not truck and I click the button to sort by "truck" then the search result goes blank, which is ok. But if I click "car" or "show all" to display everything again then the search result stays blank.

This doesn't happen with records that contain both "car" and "truck."

For every button I have something like this: DoCmd.OpenForm "AdminSearchResults", , "SOW", "VendName = '" & VendName & "'", , , "'VendName'"

I know my explanation may suck, but if anyone can help me, that would be great, lol
 
Change each button to open the form and then set the recordsource of the form using sql, example:
Code:
DoCmd.OpenForm "AdminSearchResults"
Form_AdminSearchResults.RecordSource = "SELECT * FROM yourtable WHERE VendName ='" & VendName & "'"
Repeat this for each button and tailer the SQL to the specific criteria for that button.
 
Thanks, but I'm still having the same problem
 
The problem seems to be that the value for 'VendName' is getting reset to Null if there are no search results when one of the buttons is clicked. How do I fix this?
 

Users who are viewing this thread

Back
Top Bottom