Querying within a report?

C

CJones

I work with a large database where we track study subjects' participation in
activities and questionnaire returns. I have created a report based on a
query to streamline a certain process using a parameter that allows me to
search by subject ID number to pull up relevant information. Is there any
way, once I am in the report, to enter a different subject ID number so I can
move to different subjects within the report screen without closing out of it
each time and reopening with a new ID number in the parameter field? Thanks.
 
M

Marshall Barton

CJones said:
I work with a large database where we track study subjects' participation in
activities and questionnaire returns. I have created a report based on a
query to streamline a certain process using a parameter that allows me to
search by subject ID number to pull up relevant information. Is there any
way, once I am in the report, to enter a different subject ID number so I can
move to different subjects within the report screen without closing out of it
each time and reopening with a new ID number in the parameter field? Thanks.


Not by using a simple parameter query as the report's record
source.

Try this kind of scenario after removing the patameter
prompt from the query. Use a form with a text box to enter
the ID and a button to trigger running the report, then the
form can open the report using the OpenReport method's
WhereCondition argument (this sets the report's Filter
property). Then you can just reset the filter property to
rerun the report with the new filter.

The button's code could be something like:

Dim stWhere As String
stWhere = "ID = " & Me.txtID
If CurrentProject.AllReports![report name].IsLoaded Then
Reports![report name].Filter = stWhere
Else
DoCmd.OpenReport "report name", acviewPreview, , stWhere
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top