Use a public string variable to act as the filter for your report.
1. Create the variable.
In the General Declarations (top) of a standard module (one created from the
Modules tab of the Database Container), add this line:
Public gstrReportFilter As String
2. In the Open event procedure of the report, apply and reset the variable:
Private Sub Report_Open(Cancel As Integer)
If gstrReportFilter <vbNullString Then
Me.Filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = vbNullString
End If
End Sub
3. In the code that performs the OutputTo, set the string variable first,
e.g.:
gstrReportFilter = "[ID] = 999"
DoCmd.OutputTo ...
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Jim Devenish" <in***************@foobox.comwrote in message
news:11*********************@o80g2000hse.googlegro ups.com...
>I have a report which can be displayed on the screen with:
DoCmd.OpenReport "RemittanceAdvice",acViewNormal,,"PaymentID = " &
paymentRecID
I now wish to create a snapshot of this, using the OutputTo command.
Well really I am wishing to use Stephen Lebans procedure to create a
PDF file and an important step in this is the use of the OutPutTo
command:
DoCmd.OutputTo acOutputToReport, RptName, "SnapshotFormat(*.snp)",
strPathandFileName
My problem is how to handle the Where condition in the OpenReport
statement. The OutputTo command does not provide for this. Simply
naming the report will produce too much output i.e. all records
instead of a selected one.
Any thoughts on how to handle this would be welcome.