473,320 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Use of OutputTo for a report with a Where condition

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.

Oct 10 '07 #1
2 8217
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.
Oct 10 '07 #2
Allen

Thank you for the suggestion. I do not like global variables in
general but I can see the merit on this occasion and can see how it
will work.

Jim
Oct 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ima Lostsoul | last post by:
I have an application that is being used in both the retail and run time Access (XP). One feature is that reports can be exported to SnapShot files. I have a custom menu for the reports and VB...
5
by: Mal | last post by:
Hi, I have a button on a form that outputs a report to word. While it has been working well for a while, today it is not. The behaviour now is that it endlessly outputs pages to word. There...
0
by: Neil Ginsberg | last post by:
I was using SendTo to e-mail a report in my database. However, the client uses Outlook with Exchange, which doesn't allow attachments to be sent via SendTo. So I converted it to MAPI code. The new...
1
by: paul.hanti | last post by:
This board has been a plethora of information. Thanks to all that respond! I have a quick question regarding the built-in OutputTo macro. I've built a shared database in Access 2003 (in Access...
5
by: sara | last post by:
I have reports that run from a form where the user can choose a date range, or they run automatically for a week in the "Weekly Reports" option. I created 2 queries and 2 reports - one query...
2
by: Thall | last post by:
Hey Gurus - I've seen a few solutions to this problem, but none of which I can do without a little help. Here's the situation The following code loops thru a sales report, using the sales rep ID...
3
by: ljungers | last post by:
I need to make some changes to a Query/select/print report using word application. What I need to do is change the way Word is called yet keep the process the same. Word is used so changes can be...
5
by: dancole42 | last post by:
I have a question regarding the DoCmd.OutputTo function. I have an invoice report that shows all of the invoices for a particular date. I want to create a button that will export each page of...
2
by: Mark | last post by:
Hi All, I have hit a stumbling block whilst trying to automate the output a report where the source for the report is a query that contains a parameter. The query is as follows: PARAMETERS...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.