andymartnez
Registered User.
- Local time
- Today, 11:34
- Joined
- Jul 2, 2013
- Messages
- 18
Hey, I'm working on making a search form for my database and have had fairly decent success in getting it functional.
On my search form are a few textboxes, comboboxes and an option group that all work with a query to search the database. the option group controls a set of 3 textboxes that are meant to function as a "keyword" search. All the keyword search does is not much more than simply searching through a field in a table labeled "keywords" that have been stored by whoever entered the record as a way of finding the record using the keyword search.
Going back to the option group, the two controls it has are "and" and "or", which should, in theory modify the query's criteria for the keyword field by making the search boxes be connected via "and" statements or "or" statements respectively.
I wanted to know if there was a way to add VBA code to my "search" button (the control that fires the query) to quickly change the query's criteria depending on whether the "and" or the "or" is selected. additionally I want it to modify the criteria depending on how many of the 3 keyword search text boxes were used. (I currently have a problem where if "or" is the criteria then if one keyword box is left blank it simply selects all of the records).
My "or" as it pertains to my problem with search results(the entire block of code is on one line of the query criteria):
On my search form are a few textboxes, comboboxes and an option group that all work with a query to search the database. the option group controls a set of 3 textboxes that are meant to function as a "keyword" search. All the keyword search does is not much more than simply searching through a field in a table labeled "keywords" that have been stored by whoever entered the record as a way of finding the record using the keyword search.
Going back to the option group, the two controls it has are "and" and "or", which should, in theory modify the query's criteria for the keyword field by making the search boxes be connected via "and" statements or "or" statements respectively.
I wanted to know if there was a way to add VBA code to my "search" button (the control that fires the query) to quickly change the query's criteria depending on whether the "and" or the "or" is selected. additionally I want it to modify the criteria depending on how many of the 3 keyword search text boxes were used. (I currently have a problem where if "or" is the criteria then if one keyword box is left blank it simply selects all of the records).
My "or" as it pertains to my problem with search results(the entire block of code is on one line of the query criteria):
Code:
Like "*" & [Forms]![search_frm]![keyword_1_search] & "*"
Or Like "*" & [Forms]![search_frm]![keyword_2_search] & "*"
Or Like "*" & [Forms]![search_frm]![keyword_3_search] & "*"
Last edited: