Output to Snapshot.

BenSteckler

Addicted to Programming
Local time
Today, 14:20
Joined
Oct 4, 2000
Messages
44
I am trying to output an Access Report to a snapshot viewer. The problem I am having is that when I call the OutputTo command, it does not allow me to change the filter. It just opens the whole report. Can anyone look at the following code and tell me what I am doing wrong?

Code is written in VB6.

Code:
    Dim appAccess As Access.Application, LimitsAre As String
    Set appAccess = New Access.Application
    appAccess.OpenCurrentDatabase ("i:\[I]NameOfFile.mdb[/I]")
    
    LimitsAre = "([SignInId] = '"  & frmSignIn.txtActiveXId & "')"
    
    appAccess.DoCmd.OpenReport "Issue Log Report - Analyst" _ 
        , , , LimitsAre
    appAccess.DoCmd.OutputTo acOutputReport, _ 
        "Issue Log Report - Analyst", acFormatSNP, _ 
        "i:\[I]NameOfSnapFile.snp[/I]", True
    appAccess.CloseCurrentDatabase
    appAccess.Quit
    Set appAccess = Nothing
    MsgBox "Your Issue Log has been printed.", , "Printed Complete."

Thanks for the help,
BDS
 
Last edited:
snapshot

Rethink your approach. You are currently changing the filter on an instance of the report, not the report itself. Go to the report object and lookup the filter property. Then assign the filter you have to the report filter propery. Try this (all within your code). That changes the report object property to the filter you want. Then your output should work.
 
Thanks for the update.

I have tried this code to apply the filter to the report itself but I am getting an error. The error states that there is no Report by that name. But I know that the report is named correctly.

Could you assist me with this code?

This code was placed just prior to the OutputTo command in the code above.

Code:
    appAccess.Reports("Issue Log Report - Analyst").Filter = LimitsAre

Thanks
BDS
 
snapshot report

Use this code as a sort of example

Function TestRpts()
Dim strRptName As String
Dim StrLimitsAre As String
Dim rptReport As Report

Set rptReport = New NameOfReport
strRptName = "NameOfReport"
StrLimitsAre = "Dept = " & """MentalWard"""
rptReport.Filter = StrLimitsAre
rptReport.FilterOn = True

DoCmd.OutputTo acOutputReport, strRptName, acFormatSNP, , True

rptReport.FilterOn = False
rptReport.Filter = ""
Set rptReport = Nothing
Debug.Print StrLimitsAre

End Function

I used this to create a snap report from one of my reports. There may be better ways to do this, but it worked.
 
dropping out

I just realized that you are coding in VB6 not VBA. My answer may not apply or any bearing on your question.
 
Re: dropping out

fuzzygeek said:
I just realized that you are coding in VB6 not VBA. My answer may not apply or any bearing on your question.
Sorry for the newbie question but what is the difference betwen VB6 and VBA in Access??
:confused:
 

Users who are viewing this thread

Back
Top Bottom