Option Group

  • Thread starter Thread starter PBrown
  • Start date Start date
P

PBrown

Here is some background...
1) Query has a "Deleted" field that can be checked when a
project has been removed from the planning
2) There are two forms that will be used to allow users
to pick which area they want to view.
A) Form A is for managers only and can only be reached
via passwords
B) Form B is for use by anyone.
3) The same report runs, despite which form the user
uses. The only difference is the choices of titles
(Another option group already in play here)
4) Another option group has been set up with (3) radio
buttons 1 - Current 2 - Deleted 3 - All

Question:
Is there away to have the query or report use #4's result
to run. I.E. if the user clicks on "Deleted" only
deleted items appear, etc.
The problem is that I do not believe the query can be
tied only to this form. Because as mentioned earlier,
there are (2) forms that use the query for its report
(s). Someone was telling me about, Via the
Docmd.OpenReport method (you used to launch your report),
set the filter (or Where) argument to what the user
selected. However, I have looked at "Help" and many on-
line sources, but am having trouble finding references or
examples that involve using an item selected on a form as
a filter. Any suggestions?

Thank you in advance for any and all help,

PBrown
 
It's possible to have a query use the value of a form's control as a
criterion for filtering the query's results. With an option group, you can
set the value of the option buttons to match what your query is expecting
for a field's value, such as -1 (for True) and 0 (for False). You use a
reference similar to this in the query to get the value of the form's
control:
Forms!FormName!OptionGroupName

If the query cannot be limited to just this form's option group, then you'd
need to use VBA code to open the QueryDef object, resolve the parameter
(criterion) to be the value from the option group, change the SQL of the
query to include the actual value of the parameter and save that new SQL
into the query, and then open the report that uses that query as its
recordsource.

By the way, you could have separate queries for each form....this would
greatly simplify what you need to do.
 
Back
Top