Simple filter not working (1 Viewer)

Tupacmoche

Registered User.
Local time
Today, 08:27
Joined
Apr 28, 2008
Messages
291
Hi Report Masters,

I have a case statement that selects a report to use based on a value in the table. This works fine but the DoCmd.OpenReport filter is not. The case statement in triggered by the on click event of the print button, I'm trying to filter on the current record on the form by passing the id in the where clause of the DoCmd.OpenReport is my syntax wrong it dose not work.:confused:

Select Case [GiftType]
Case "Pledge"
DoCmd.OpenReport "Pledge_Transmittal_Rpt", acViewPreview, , "DonorAdvanceID ='" & DonorAdvanceID

Case "Pledge Payment"
DoCmd.OpenReport "Gift_Transmittal_Rpt", acViewPreview
"DonorAdvanceID ='" & DonorAdvanceID

End Select
 

isladogs

MVP / VIP
Local time
Today, 12:27
Joined
Jan 14, 2017
Messages
18,186
Assuming DonorAdvanceID is a number field, replace the parts in RED with
Code:
"DonorAdvanceID =" & Me.DonorAdvanceID
I have removed the single quote.
In the second case statement, you also need a comma after acViewPreview.

If it's a text field then you need text delimiters
Code:
"DonorAdvanceID = '" & Me.DonorAdvanceID & "'"
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:27
Joined
Feb 19, 2013
Messages
16,555
For future reference 'does not work' does not help us to help you. Explain what it means

You should clarify what the datatype is, you have

"DonorAdvanceID ='" & DonorAdvanceID

is a mixture of text and numeric.

if DonorAdvanceID is text then you need

"DonorAdvanceID ='" & DonorAdvanceID & "'"

and if it is numeric you need

"DonorAdvanceID =" & DonorAdvanceID
 

Tupacmoche

Registered User.
Local time
Today, 08:27
Joined
Apr 28, 2008
Messages
291
Hi CJ_London,

I will be more descriptive the next time. Thanks!:)
 

Users who are viewing this thread

Top Bottom