Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filter report from combo box in form pt.2 1

Status
Not open for further replies.

trustsun

Technical User
Feb 4, 2004
73
US
Scriverb, need your advice again.

Using this code I have been filtering a report by two combo boxes. The report will not display unless both combo boxes are updated. Now I would like to have either or both combo boxes blank or use as an option if the users want to filter the report.
If your or someone could revise this where as the combo boxes would be blank or updated and the report can still be viewed, print, file or emailed when the button is click.


Private Sub Command7_Click()

On Error GoTo MyErr
If IsNull(Me.Combo0) Then
MsgBox "No Selection Made to run report.", vbCritical, "Selection Required "
Me.Combo0.SetFocus
Me.Combo0.Dropdown
Else
If Not IsNull(Me.Combo0) Then
strFilter = "[myfield1]= '" & Me![Combo0] & "'"
strFilter = strFilter & " and [myfield2]= '" & Me![Combo2] & "'"
DoCmd.SendObject acReport, "MyReport"

MyExit:
Exit Sub
MyErr:
If Err.Number <> 2501 Then
MsgBox Err.Description
End If
Resume MyExit
End If
End If
End Sub
 
Something like this ?
strFilter = "[myfield1]=" & Nz("'"+Me![Combo0]+"'", "[myfield1]") & " AND "
strFilter = strFilter & "[myfield2]=" & Nz("'"+Me![Combo2]+"'", "[myfield2]")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Now I need to this with three combo boxes,made a feable attemp to do myself, error with a "data type mismath" could you help me again.

thanks, "Trust
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top