Multiple filters

B

Billy Banter

Can anybody give me some guideance regarding multiple filters on a report.

I want something like this.

On Error GoTo Err_Command20_Click

Dim stDocName As String

stDocName = "AuditReport"
DoCmd.OpenReport stDocName, acPreview, , "ClaimType=
forms!form1!ClaimType" & "MethodNo= forms!form1!MethodNo"
Exit_Command20_Click:
Exit Sub

Err_Command20_Click:
MsgBox Err.Description
Resume Exit_Command20_Click

End Sub

Regards
Billy
 
D

Duane Hookom

Assuming ClaimType and MethodNo are both numeric.
Dim strWhere as String
strWhere = "ClaimType= " & forms!form1!ClaimType
strWhere = strWhere & " And MethodNo= " & forms!form1!MethodNo
DoCmd.OpenReport stDocName, acPreview, , strWhere
If either of the fields arestring then you will need to concatenate double
or single quotes around the control references.
 
B

Billy Banter

Thanks for the reply, I worked out another way as well.

Dim stDocName As String

stDocName = "AuditReport"
DoCmd.OpenReport stDocName, acPreview, , WhereCondition:="MethodNo = " &
Me.MethodNo _
& " AND ClaimType = " & Me.ClaimType
 
D

Duane Hookom

Your method works fine also. I like to build the where condition in a
variable and then use the variable in the OpenReport method. It's a matter
of style.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top