Re: Query criteria that isn't bound to a single form or report
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Thu, 2 Mar 2006 09:52:00 +0800
Megan, to make it flexible, leave the criteria out of the query.
Instead, use the WhereCondition of OpenReport.
For a couple of examples of building the WhereCondition string, see:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html
and:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html
Each form can then build its own critiera, and re-use the same report.
You can actually make this very flexible, offering the user lots of choices
to filter the report, and just building the WhereCondition from the controls
where the user actually entered something. For an example of that, download
the example database in this link:
http://allenbrowne.com/unlinked/Search2000.zip
The example is just a few kilobytes, and requires Access 2000 or later. The
example shows how to build the string to apply as the Filter for a search
form, but the technique is identical for building the WhereCondition for
OpenReport.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
<mgolding@xxxxxxxxx> wrote in message
news:1141254709.810998.312340@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have an Access query that gets an ID value from an open form.
Something like
SELECT * from tablename WHERE ID=openFormName.ID;
But now, I want to also run the query by handing it the ID from a
report.
How do I set the Criteria for a query so it can take the ID value from
either the form or the report (or any source I call the query from)?
Many thanks for considering my question,
Megan Golding
.
- Follow-Ups:
- Re: Query criteria that isn't bound to a single form or report
- From: mgolding@xxxxxxxxx
- Re: Query criteria that isn't bound to a single form or report
- References:
- Query criteria that isn't bound to a single form or report
- From: mgolding@xxxxxxxxx
- Query criteria that isn't bound to a single form or report
- Prev by Date: Re: Records Getting Deleted from Key Table
- Next by Date: Lebans Rich Text Control LDB/Locking Problem
- Previous by thread: Query criteria that isn't bound to a single form or report
- Next by thread: Re: Query criteria that isn't bound to a single form or report
- Index(es):
Relevant Pages
|