Reports with multiple Criteria’s

G

Gus Chuch

I have a report that uses a query for a record source and this query uses a
criteria so I can print only one record based on the opened form.
[FORMS]![frmNAME]![Criteria]
My question is can I have more that one criteria , like -
[FORMS]![frmNAME1]![Criteria1]
[FORMS]![frmNAME2]![Criteria2]
[FORMS]![frmNAME3]![Criteria3]
So I can print the same report from different forms?
If so how wold this be done?
 
D

Duane Hookom

I try not to place any "dynamic" criteria in a query used as record sources
for forms or reports. You have much greater control and flexibility if you
use the "where" clause in the DoCmd.OpenReport method.

Dim strWhere as String
strWhere = "1 = 1 "
If not IsNull(Me.txtStartDate) Then
strWhere = strWhere & " And [DateField]>=#" & _
Me.txtStartDate & "# "
End If
If not IsNull(Me.txtEndDate) Then
strWhere = strWhere & " And [DateField]<=#" & _
Me.txtEndDate & "# "
End If
'-- more criteria?
DoCmd.OpenReport "rptYourReport", acPreview, , strWhere
 
Top