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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering subform records

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
579
0
16
GB
Hellow,

I have code to filter a subform which works OK below - it basically applies a filter in the field LOG TYPE from a combobox called FILTERS

If the combobox contains nothing it returns all records.

I would like to alter the code to work pretty much the same, but return all records if the combobox contains nothing or the word "ALL"

My attempt is the second block of code, but it caused my whole program to crash!!!!

Can someone show me the way???

Thanks, Mark



Private Sub FILTERS_AfterUpdate()

If Len(Nz(FILTERs, "")) > 0 Then
Forms![#edit_details]![#MASTER_LOGS].Form.FILTER = "[LOG TYPE]= '" & FILTERs & "'"
Forms![#edit_details]![#MASTER_LOGS].Form.FilterOn = True
Else
Forms![#edit_details]![#MASTER_LOGS].Form.FILTER = ""
Forms![#edit_details]![#MASTER_LOGS].Form.FilterOn = False
End If

End Sub
 
My attempt is the second block of code
Which code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Oops

Private Sub FILTERS_AfterUpdate()

If FILTER = <>ALL Then
Forms![#edit_details]![#MASTER_LOGS].Form.FILTER = "[LOG TYPE]= '" & FILTERs & "'"
Forms![#edit_details]![#MASTER_LOGS].Form.FilterOn = True
Else
Forms![#edit_details]![#MASTER_LOGS].Form.FILTER = ""
Forms![#edit_details]![#MASTER_LOGS].Form.FilterOn = False
End If

End Sub
 
Replace this:
If FILTER = <>ALL Then
with this:
If Trim(FILTERs & "") <> "" And FILTERs & "" <> "ALL" Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top