Advertisement

05.07.2008 at 02:40PM PDT, ID: 23384392
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

How do I add a filter to a report when using DoCmd.OutputTo
Tags: Microsoft, Access, 2003, VBA
I am trying to send faxes in an Access application.  I have various reports that I want to send out to different clients.  However, in order for my fax program to work it needs to a fax a file, it can't fax a report.  So the sollution is to loop thru my clients and output my reports to a .snp file.

I'm using the following code to do so:

        DoCmd.OutputTo acOutputReport, "rptFax2", acFormatSNP, strFile, False

However this DoCmd.OutputTo function doesn't allow me to apply a filter the report, which is neccessary so that I only send a client their data.

Does anyone know how to apply filter in this situation, or another way of outputting a file that allows filters?

Thanks

Ben
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: valencehealth
Solution Provided By: harfang
Participating Experts: 3
Solution Grade: A
Views: 6
Translate:
Loading Advertisement...
05.07.2008 at 02:45PM PDT, ID: 21520604

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 02:51PM PDT, ID: 21520653

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 02:58PM PDT, ID: 21520700

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 03:09PM PDT, ID: 21520776

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 03:17PM PDT, ID: 21520835

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 03:36PM PDT, ID: 21520953

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 09:18PM PDT, ID: 21522320

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 12:40AM PDT, ID: 21522967

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 09:02AM PDT, ID: 21525897

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 01:24PM PDT, ID: 21528143

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 01:35PM PDT, ID: 21528226

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 03:10PM PDT, ID: 21528892

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 04:00PM PDT, ID: 21529155

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 09:33AM PDT, ID: 21534480

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.07.2008 at 02:45PM PDT, ID: 21520604

Rank: Genius

In a case like this I dynamically create the query before activating the report.

Make sure that a reference is opened for the DAO library then you can use:

dim qd as DAO.querydef

set qd = currentdb.querydefs("qryReport2")

qd.SQL = "select * from tblX where customerid=" & Me.CustomerID

'==> Here execute the DoCmd.OutputTo

Keep in mind that the "qryReport2" is filled dynamically and that the real content (when you use the original report query) will be overwritten!

Getting the idea ?

Nic;o)
 
05.07.2008 at 02:51PM PDT, ID: 21520653
Yes, that makes sense, I was thinking of doing something like that.  I was hoping however that there may be a cleaner way of doing this.  I plan on making lots of different reports faxable and I don't really want to have to make 2 copies of each one (one with no filter which I can use for display, and one that has this dynamically changing filter).
 
05.07.2008 at 02:58PM PDT, ID: 21520700

Rank: Genius

You could re-use the report-preview query like:

qd.SQL = "select * from qryReport2 where customerid=" & Me.CustomerID

Thus no separate query for the preview is needed....

Nic;o)
 
05.07.2008 at 03:09PM PDT, ID: 21520776
I'm not sure I understand.  Wouldn't that be telling it to select from itself and creating an infinite loop?
 
05.07.2008 at 03:17PM PDT, ID: 21520835

Rank: Genius

No, it's selecting from the (not limited) report query that's used for the preview.
You'll only have to define one additional "qryDummy" that can be used to store the (temp) created query string of all reports.
So the full code would look like:

dim qd as DAO.querydef

set qd = currentdb.querydefs("qryDummy")

qd.SQL = "select * from qryReport2 where customerid=" & Me.CustomerID

'==> Here execute the DoCmd.OutputTo

Clearer ?

Nic;o)
 
05.07.2008 at 03:36PM PDT, ID: 21520953

Rank: Genius

Hmm, have to change the approach when you want no extra query.
We will have to store the query content before execution, use it and restore it afterwards like:

dim qd as DAO.querydef
dim strSQLsave as String

set qd = currentdb.querydefs("qryReport2")
strSQLsave = qd.SQL
' the Replace is needed to get rid of the ; query termination character
qd.SQL = "select * from (" & replace(strSQLsave,";","") & ") where customerid=" & Me.CustomerID
'==> Here execute the DoCmd.OutputTo
qd.SQL = strSQLsave

Thus the change is undone.

Nic;o)
 
05.07.2008 at 09:18PM PDT, ID: 21522320

Rank: Genius

Hello again, Nico, glad you're back. I hope I'm not ruining your comeback with this alternate solution... (^v°)

    DoCmd.OpenReport "rptFax2", acViewPreview, WhereCondition:="ClientID=1"
    DoCmd.OutputTo acOutputReport, , acFormatSNP, strFile, False
    DoCmd.Close acReport, "rptFax2"

If the report is already open, OutputTo doesn't reopen it, and just uses the current instance (in this case the active report, since I didn't repeat the report name).

Cheers!
(°v°)
 
05.08.2008 at 12:40AM PDT, ID: 21522967

Rank: Genius

Hi Markus, I always like different solutions and this one look promising, just what happens when the user already opened this (or another) report in preview before and starts this code, will Access use the last opened report ?

Nic;o)
 
05.08.2008 at 09:02AM PDT, ID: 21525897

Rank: Genius

<offtopic>

Nico,

Welcome back!

Regards,

Patrick

</offtopic>
 
05.08.2008 at 01:24PM PDT, ID: 21528143

Rank: Genius

> will Access use the last opened report ?

Yes. When the name of the report is left blank, it seems that Screen.ActiveReport is used. But why take chances: let's just repeat the report name, so it can even be opened in a hidden window to avoid flicker.

    DoCmd.OpenReport "rptFax2", acViewPreview, , "ClientID=1", acHidden
    DoCmd.OutputTo acOutputReport, "rptFax2", acFormatSNP, strFile, False
    DoCmd.Close acReport, "rptFax2"

(°v°)
Accepted Solution
 
05.08.2008 at 01:35PM PDT, ID: 21528226

Rank: Genius

Looks nice,  and the acHidden will solve the only back draw to this solution, being the visible opening and closing of multiple reports.
Are you sure that adding the "rptFax2" to the DoCmd doesn't trigger the "entire" report, overwriting the set WHERE parameter?

(Always looking for flaws, you know me <LOL>)

Nic;o)
 
05.08.2008 at 03:10PM PDT, ID: 21528892

Rank: Genius

Yes, Nico, I'm quite sure. DoCmd never opens two instances of the same form or report, even "internally" or when one is hidden. Besides, I tested my suggestion before posting.

(^v°)
 
05.08.2008 at 04:00PM PDT, ID: 21529155

Rank: Genius

>"I tested my suggestion before posting"
I should have known :-)

Great solution and taught me a new trick, thanks !

Nic;o)
 
05.09.2008 at 09:33AM PDT, ID: 21534480
That code worked perfectly.  Thanks for the help.

Ben
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628