Solved

How do I filter report export to Word

Posted on 2011-02-17
5
408 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
  • 3
  • 2
5 Comments
 
LVL 18

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 18

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now