Multiple Combo Box for Report

S

SAQ

I am working with multiple combo boxed to report based on selected criteria.
Some of the combo boxes may not have been selected. If I was using this as
the source for the report and saying = combo1 & combo2 & combo3 the
resulting output would not work as combo2 may be blank making the result
invalid. Is there a straightforward way of achieving this.
 
D

Duane Hookom

The method I use is like:

Dim strWhere as String
strWhere = " 1=1 "
If Not IsNull(Me.ComboEyes) Then
strWhere = strWhere & "AND [EyeColourID] =" & Me.ComboEyes
End If
If Not IsNull(Me.ComboHair) Then
strWhere = strWhere & "AND [HairColourID] =" & Me.ComboHair
End If
'etc
DoCmd.OpenReport "rptYourReport", , , strWhere
 

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