Printing a Report

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

I have a form that comes from a query, when the Report #
is entered it brings up a single record. I need to print a
report from the current record that is displayed on the
form. This report also comes from the same query as the
form. Is there any way to make the print button print the
current record without asking the user to enter the report
# again ? Thanks
Doug
 
Doug said:
I have a form that comes from a query, when the Report #
is entered it brings up a single record. I need to print a
report from the current record that is displayed on the
form. This report also comes from the same query as the
form. Is there any way to make the print button print the
current record without asking the user to enter the report
# again ?


You can filter a report by using the OpenReport method's
WhereCondition argument. If you'll look at the code in the
form's module and find the button's Click event, then change
it to be along these lines:

Dim stDoc As String
Dim stWhere As String
stDoc = "nameof report"
stWhere = "primarykeyfield = " & Me.primarykeytextbox
DoCmd.OpenReport stDoc, acViewPreview, , stWhere
 
Back
Top