Printing a single record on a Report in Acess 2002

J

jib24

Does anyone know how to display only a single record on a report? I
have the report linked to a table and Id rather not linked it to a
query. Essentially, I want to display a list of records (which
represent projects in my case) and have the user choose the project
using a combo box and then produce a report that has only the record
chosen by the user. Is there a possible way to use VBA to display only
one record on a report?

Thanks a lot.

J
 
M

Marshall Barton

Does anyone know how to display only a single record on a report? I
have the report linked to a table and Id rather not linked it to a
query. Essentially, I want to display a list of records (which
represent projects in my case) and have the user choose the project
using a combo box and then produce a report that has only the record
chosen by the user. Is there a possible way to use VBA to display only
one record on a report?


Use the OpenReport method's WhereCondition argument to
filter the report's dataset when it is opened.

Your form's print report button already has code to open the
report, so just modify it to include the filtering string.
If the project ID field is a numeric type, use:
stLinkCriteria = "[Project ID field]=" & [combo box]

If the project ID field is a numeric type, use:
stLinkCriteria = "[Project ID field]='" & [combo box] &"'"

And change the OpenReport line to:
DoCmd.OpenReport stDoc, , ,stLinkCriteria
 

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