Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Engine Code

Status
Not open for further replies.

DBStarter

MIS
May 26, 2005
1
US
I am a novice and am creating a form whereby the user may select multiple criteria based on combo box selections on a form.
First: They will press a toggle button (name of category - optBusinessUnit, optProduct, optSource) which will enable the combo box (ie. cboBusinessUnit, cboProduct, cboSource) to the right of it, then select one of the choices listed within the combo box for each combo box selected. I have already coded the objects.

I am having a problem figuring how to write the code that will enable the SEARCH button to populate the list box (lstWhichChoice) and the PRINT button to print the report called: SUMMARY.

Please help.

 
Base the listWhichChoice control on a query and inside that query have your criteria set to either be equal to what is in the combobox or like &quot;*&quot; & <whats in a text box> & &quot;*&quot;. Then every time you click SEARCH, in your code just requery the list object.

If you need more help with the VBA code behind the SEARCH button let me know I can post some sample code from one of my databases to show you.
 
Sameal

Thanks for your input and yes, it would be very helpful to view your code, because I was unable to locate any examples for such a query.

More info:
The user may select a criterion for any number of combo boxes to be searched simultaneously:,ie, cboBusinessUnit = &quot;PC&quot;, cboSource = &quot;Advertisement&quot;, cboCountry = &quot;France&quot;, etc.

<SEARCH>

Show all records where: Source = Advertisement, BusinessUnit = PC, Country = France.
 
Create a query based upon the table you want to search. In this case I think its easier to use the QEB because it will make the monstrous SQL statement for you. Under each field that you will be searching for there is a Criteria box...in these boxes you will put the refrence to the field on the form such as [Forms]![frmYourMainForm]![cboBuisnessUnit] etc etc. Be sure that your combo boxes are using the key field as their bound field other wise you'll have to use string matching. If you decide to put a text box in to search with use the following criteria or any you find that work better &quot;Like &quot;*&quot; & [Forms]![frmYourMainForm]![txtDescription] & &quot;*&quot;&quot;

Once you have your query built, base both your forms off that query. The only thing left now is to code the Search button. All this button needs to do is Requery the main and subforms. You can accomplish this using either macros or VBA code. Whatever your more comfortable with. One way to do it in VBA however is.

dim frmMyForm as Form
dim subMyForm as subForm

set frmMyForm = [Forms]![frmYourFormName]
set subMyForm = [Forms]![frmYourFormName]![frmYoursubFormName]

frmMyForm.Requery
subMyForm.Requery

set frmMyForm = Nothing
set subMyForm = Nothing


Let me know if this helps you out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top