Solved

How do I filter report export to Word

Posted on 2011-02-17
5
422 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

729 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