View Single Post
  #7  
Old January 21st, 2009, 03:43 AM posted to microsoft.public.access.gettingstarted
Ken Snell \(MVP\)
external usenet poster
 
Posts: 2,506
Default One Query, different criteria

If you open a form that shows the filtered data, you can base that form on
the query without the criterion string, and put the built WHERE clause info
into the fourth argument of the DoCmd.OpenForm method:

DoCmd.OpenForm "NameOfForm", , , "FieldName='SomeValue'"

Doing this in a subform is a bit more tricky, because you cannot use the
DoCmd.OpenForm action. Instead, you'd need to change the subform's
RecordSource to be the SQL statement of the filtered query:
SELECT * FROM QueryName WHERE FieldName = 'SomeValue'

(Alternatively, you can apply a filter to a subform, but changing the
RecordSource is easier, I think.)

A report can be done similarly to the form, except that you'd use the
DoCmd.OpenReport action.

Is the subform the way you want to go? Is it in the same form where your
user selects the desired values on the form? Can you give us details about
form names, subform SourceObject name, subform control name, etc.?
--

Ken Snell
MS ACCESS MVP
http://www.accessmvp.com/KDSnell/




"CK1 via AccessMonster.com" u48386@uwe wrote in message
news:9076fdcb9ab0a@uwe...
Ken, the queries will be run to show the user where the gaps are in their
files or, conversely, which files are complete. So far I have presented it
as
a subform (in datasheet view) in a form. I anticipate that a report could
be
useful too, but a form initially.

Thanks again
best wishes
CK

Ken Snell (MVP) wrote:
To what end use will the queries be put? For display on a form? For
display
in a report? For exporting to a file?

Thanks Ken. I've had a look at this and I must admit that the SQL
language
is

[quoted text clipped - 25 lines]
Cheers
CK1


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...arted/200901/1