Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I filter report export to Word

Posted on 2011-02-17
5
Medium Priority
?
433 Views
Last Modified: 2012-05-11
Hello Experts,

I am using some VB code to print a report using a filter:

'DoCmd.OpenReport stDocName, acViewNormal, , strFilter  (see code below)

However, since I needed to print the report in .rtf format for MS Word has to use:
 
DoCmd.OutputTo acOutputReport, "rptTrip", acFormatRTF

I do not see an argument for filter but I need to filter the report when I save as RTF.

How can I continue to filter the report?

Thanks!





Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click
 Dim iViewMode As Integer
 Dim stDocName As String
 Dim strFilter As String
 
 Forms.frmTrip.Dirty = False  'save the record before printing

 stDocName = "rptTrip"
 
 strFilter = "[IDtrip] = Forms!frmTrip!IDtrip"

 Select Case MsgBox("Preview report before printing?", vbQuestion Or vbYesNoCancel)
   Case vbYes
       DoCmd.OpenReport stDocName, acViewPreview, , strFilter
   Case vbNo
       DoCmd.OutputTo acOutputReport, "rptTrip", acFormatRTF

       'DoCmd.OpenReport stDocName, acViewNormal, , strFilter


   Case vbCancel
     GoTo Exit_cmdPrint_Click
 End Select
   
  
Exit_cmdPrint_Click:
    Exit Sub

Err_cmdPrint_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrint_Click
End Sub

Open in new window

0
Comment
Question by:shogun5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:Richard Daneke
ID: 34922376
Could this be the issue.  First create the report, then output the report to Word.

   Case vbNo  
        'oCmd.OpenReport stDocName, acViewNormal, , strFilter  
        DoCmd.OutputTo acOutputReport, "rptTrip", acFormatRTF  
 
       
 
0
 
LVL 19

Expert Comment

by:Richard Daneke
ID: 34922381
Reposting, typing error:

Could this be the issue.  First create the report, then output the report to Word.

   Case vbNo  
        DoCmd.OpenReport stDocName, acViewNormal, , strFilter  
        DoCmd.OutputTo acOutputReport, "rptTrip", acFormatRTF  
0
 

Author Comment

by:shogun5
ID: 34922408
Nope.

In the example above the report prints WITH the filter then is saved as an .rtf file without filters.

I am sure there is a way to do this...I just don't know how... hmmm
0
 

Accepted Solution

by:
shogun5 earned 0 total points
ID: 34922840
Found the answer here:

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_22130553.html

I just matched the report's source filter to the form's.
0
 

Author Closing Comment

by:shogun5
ID: 36923080
Found the answer myself that bets fit the solution
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question