Print Report based on current record in form.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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.
 
Back
Top