Print Report based on current record in form.

R

Rose

I know how to open a form to a specific record but I am having a hard time
opening a report to a specific record from a form. Any suggestions rather
then promoting a query to ask for an ID number then manually inputting it?
 
B

Brendan Reynolds

Use the optional 'WhereCondition' argument of the OpenReport method to
specify which record(s) should be included. For example, this will print a
report that includes only the single record with the value in the EmployeeID
field that matches the value of the EmployeeID text box on the form ...

DoCmd.OpenReport "rptEmployees", acPreview, , "EmployeeID = " &
Me.EmployeeID

The help files have an example, though it's not immediately obvious. If you
open the help topic on 'OpenReport Method' it says 'The OpenReport method
carries out the OpenReport action in Visual Basic.' The second instance of
'OpenReport' in that sentence is a hyperlink. Follow that link for more
information, including an example using the WhereCondition argument.
 

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