Problem with OutputTo method and filters

hammerva

Registered User.
Local time
Today, 21:01
Joined
Dec 19, 2000
Messages
102
I am trying to create a process that allows the user to send a report to disk. I created the check box and everything. I was able to get the report to disk but without any filter. I did some search and looked at sample code and tried this code:

' check to see if there is any data before creating reports
If CheckData("Peer Review") Then
stDocName = "Peer Review Report"
If Me.Print_Option = 1 Then
DoCmd.OpenReport stDocName, acNormal, , StLinkCriteria
Else
If Me.Print_Option = 2 Then
DoCmd.OpenReport stDocName, acViewPreview, , StLinkCriteria
Else
Set rptReport = New stDocName
rptReport.Filter = StLinkCriteria
rptReport.FilterOn = True
DoCmd.OutputTo acOutputReport, rptReport, acFormatRTF, , True
End If
End If
Else
End If


But I get an error message saying set command saying 'User defined type not defined'. Obviously I am screwing up something in this. Could you please explain what I am missing here or if there is a better way to do an OutputTo with filters.

Thanks again :)
 
You have not defined the stLinkCriteria...

For example:

stLinkCriteria = "[MemberID] = " & Me.MemberID

Open the report where the Memeber ID equals the Memeber ID textbox on the form.

HTH
 
Actually I did but the code was so long I didn't want to put it all on the board. Here is a bit of it:

If Me.Status_Number.Value <> "" Then
StLinkCriteria = "[Status_Number] = " & Me.Status_Number.Value
First_Record_Flag = "Y"
Else
End If


There is about 3 or 4 more IF statement in that. I know the criteria is working because I can print and preview with no problem
 
When you debug...which line is highlighted?
 
Nope no luck. Now I get an error saying 'Type Mismatch' which makes sense since I get rptReport as a type of Report while stDocName is a string.
 

Users who are viewing this thread

Back
Top Bottom