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!

A query based on an option group 1

Status
Not open for further replies.

popalu

Programmer
Apr 8, 2004
31
GB
Hi, I don't know if what I am trying to achieve is possible, but any help would be appreciated

I have a query (based on three tables) and it is displayed on a form. On the form i have setup an option group with 5 option buttons. I want to have the query select only the records which match the option button selected.

Here is the problem, each option button relates to a different field in the record, so I only want to query based on the option selected. Is it possible with one query or do i need 5 queries and use that data to make a table which is then displayed on the form.

eg

Each record might consist of the following
EstID, EstDate, EstEstimator,EstMaster, EstCompleted

The options are show all Est, show all for 2005, show all for Estimator, Show all Master, Show all completed.

The query needs to process only the relevant criteria based on the option button selected, not on all the criteria
 
A starting point.
The query:
SELECT ...
FROM ...
WHERE ... AND (
([Forms]![your main form]![option group]=1)
OR ([Forms]![your main form]![option group]=2 AND [theDateField]=2005)
OR ([Forms]![your main form]![option group]=3 AND [theEstimatorField] Is Not Null)
OR ([Forms]![your main form]![option group]=4 AND [theMasterField] Is Not Null)
OR ([Forms]![your main form]![option group]=5 AND [theCompletedField]=True)
);

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV, got it working, now just got to requery for updating form. Have a star m8e
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top