View Full Version : search two fields


john griffin
11-30-2001, 01:50 AM
I want to search a table based on two values, such as what dept are they in and then what country are they in. However i dont want to always have to search on both so one or the other or both options needs to be available. Also i need it to be easy so others can use it within my company?

Harry
11-30-2001, 02:14 AM
Create a form with a list box (to show the results) and then either 2 text boxes or combo boxes (depends on whether you are limiting the user to what they can search by)

You can then link the information in the listbox to be filtered by the selections from the combo box.

Sorry its brief but hopefully it will point you in the right direction. If you need any more help then repost

HTH

john griffin
11-30-2001, 03:00 AM
Thanks for your reply but im still unsure how to do it, please can you explain in a bit more detail.

Andy D
12-07-2001, 06:32 AM
Create a query and input the following IIf statement into the “Department” Field and the Country Field. Set the control suorce of your form to this query.

IIf([Forms]![ Form Name]![ Combo Name]="All",([Table Name]![Field Name]),[Forms]![From Name]![Combo Name])

Create a button on the form called “Reset” and put this simple code behind it in the onclick event

Me![Name of your first combo box] = “All”
Me![Name of your 2nd combo box] = “All”

Set the default value of the combo boxes to “All”

Create a button called Search with this code behine it.

Forms![Your form name].Requery

You can now reset both combo boxes to "All" then pick one or two options and click search, which will return the results.


[This message has been edited by Andy D (edited 12-07-2001).]

[This message has been edited by Andy D (edited 12-07-2001).]