?
Solved

How do I filter report export to Word

Posted on 2011-02-17
5
Medium Priority
?
428 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

764 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