Solved

How do I filter report export to Word

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 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

16 Experts available now in Live!

Get 1:1 Help Now