I have a report that gets filtered by a form with 2 combo boxes on. If I select data from both the combo boxes the report works fine. If I select data from th e first combo and not the second it works fine. But if I leave the first combo blank and data in the second it doesn’t work. I'd like to get it to have the ability to select either data from 1 or 2 of the combo boxes. The code is;
Dim StrRptWhere as String
If nz([Text91])<>0 then
StrRptWhere = "(Performance.Specialty =[Forms]![Performance Dynamic Report Builder]![Text91])"
end if
If nz([Text94])<>0 then
if nz(StrRptWhere) = 0 then
StrRptWhere = "(Performance.Gender=[Forms]![Performance Dynamic Report Builder]![Text94])"
else
StrRptWhere=StrRptWhere & " AND " &"(Performance.Gender=[Forms]![Performance Dynamic Report Builder]![Text94])"
end if
end if
'check StrRptWhere contains data
If NZ(StrRptWhere)=0 then
msgbox "No criteria selected",vbInformation,"Title"
exit sub
end if
DoCmd.OpenReport " Dynamic Specialty Performance ", acViewPreview, , StrRptWhere
Dim StrRptWhere as String
If nz([Text91])<>0 then
StrRptWhere = "(Performance.Specialty =[Forms]![Performance Dynamic Report Builder]![Text91])"
end if
If nz([Text94])<>0 then
if nz(StrRptWhere) = 0 then
StrRptWhere = "(Performance.Gender=[Forms]![Performance Dynamic Report Builder]![Text94])"
else
StrRptWhere=StrRptWhere & " AND " &"(Performance.Gender=[Forms]![Performance Dynamic Report Builder]![Text94])"
end if
end if
'check StrRptWhere contains data
If NZ(StrRptWhere)=0 then
msgbox "No criteria selected",vbInformation,"Title"
exit sub
end if
DoCmd.OpenReport " Dynamic Specialty Performance ", acViewPreview, , StrRptWhere