Help with VBA Report Filtering Syntax

cgdrake

Registered User.
Local time
Today, 06:07
Joined
Jul 22, 2007
Messages
38
I have the following procedure to filter a report.

Private Sub cmdCreateReport_Click()
' The section and sample numbers were chosen by the combo boxes
DoCmd.OpenReport "SampleReport", acViewPreview, , [pvmt_analysis_section_id] = '& Me.cboSectionNo &' "

End Sub


The variable pvmt_analysis_section_id is an integer. The sub is giving me an error message, 3464, saying that there is a data type mismatch.

If I change the statement to

DoCmd.OpenReport "SampleReport", acViewPreview, , "STR([pvmt_analysis_section_id]) = '& Me.cboSectionNo &' "

the procedure works, but the report comes with nothing, even though I know there is a section with that number (because the combo box is queried directly from the table.

Any help would be appreciated.
 
Try

DoCmd.OpenReport "SampleReport", acViewPreview, , "[pvmt_analysis_section_id] = " & Me.cboSectionNo
 
That did it, thanks so much!
 

Users who are viewing this thread

Back
Top Bottom