Print Report Record Matching Current Form

B

Beverly76

I have a form called FILE with a field in the Form called FileNum which is
stored in a table. On my form, I have a button to print a report. The
report is based on the table. When I click on that button, I only want to
print the report record that is equal to the FileNum and no other records.

Please help.

Thank you.
 
K

Klatuu

Use the Where Condition argument of the OpenReport method. It is the 4th
argument in the list. You can do something like this:

strDoc = "MyReportName"
strWhere = "[FileNum] = '" & Me.FileNum & "'"
DoCmd.OpenReport strDoc,,,strWhere
 
F

fredg

I have a form called FILE with a field in the Form called FileNum which is
stored in a table. On my form, I have a button to print a report. The
report is based on the table. When I click on that button, I only want to
print the report record that is equal to the FileNum and no other records.

Please help.

Thank you.

It depends upon the datatype of the FileNum field.
If it is a number datatype:
DoCmd.OpenReport "ReportName",acViewPreview, , "[FileNum] = " &
[FileNum]

If it is a Text datatype, then use:

DoCmd.OpenReport "ReportName",acViewPreview, , "[FileNum] = '" &
[FileNum] & "'"
 

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