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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query select question...

Status
Not open for further replies.

uscctechnician

Technical User
Jan 17, 2013
18
US
Hey everyone,

I am wondering what would be the best way to try and accomplish this.

I have a query, which selects data based on what employee name I select in a ComboBox. I have 4 employees and each one is assigned to 6 or 7 locations. Depending on the employee I select on the ComboBox, the query reports back to me the 6 or 7 locations for that employee.

Now the question. The 4th employee is such that if that name is selected in the ComboBox, I would like ALL locations to show on the query. I was playing around with If/Then statements on the form where this ComboBox is, but is that the most efficient way?

Thanks in Advance!!
 
Hi,

What is the table structure where this data resides?

What is the query that you use to return the location?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
This is a problem of maintainabilty vs. performance.

Generically you can in your where clause write your query for two separate conditions. However Access is rather stupid about handling OR statments in the QBE and will rewrite the SQL to something at best less efficient than you would write yourself.

So the best performance option is to have two separate queries that are pre-compiled and conditionally run the correct one... a middle ground would be to programmatically build your SQL statement for the query and execute that.

All that said, there will be nuances to performance based on the table structure and record counts etc. Which is why Skip asks the questions he does. There may be ways to improve performance outside of the exact question you are asking.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top