Preview/Print Report

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

Guest

I was given the following Code in order to just print the current record of
my form in Report view.

Private Sub Command186_Click()
Me.Refresh
DoCmd.OpenReport "rpt_Quote", , , "OrderInfoID = " & Me!OrderInfoID
End Sub

It works, but I don't understand what makes it print. What I want to do is
change it to preview rather than print but I still want it to be for the
specific record and I don't know what to change. Please help.

Thanks in Advance,
Travis
 
Just change your code to ...

DoCmd.OpenReport "rpt_Quote", acViewPreview, , "OrderInfoID = " &
Me!OrderInfoID

The second, 'view' argument to the OpenReport method is optional, if you
don't specify it it defaults to acNormal, which means send the report to the
printer.

See 'OpenReport Method' in the help files for more information.
 
When I use this, It doesn't open just the specific record. It works with the
Print Option, however the Preview option still opens every record.
 
As a reality check, I created a form and a report each bound to the Shippers
table in the Northwind database, added a command button to the form, and
added the following Click event procedure ...

Private Sub Command6_Click()

DoCmd.OpenReport "Shippers", acViewPreview, , "ShipperID = " &
Me.ShipperID

End Sub

It works just fine, the report opens in Print Preview and includes only the
record currently displayed in the form.

Are you sure you didn't change anything else?
 
Back
Top