Form combo box filter errors when blank

tritenick

Registered User.
Local time
Today, 03:56
Joined
Jul 3, 2012
Messages
10
This site is awesome and I have learned a ton reading other posts. Here is a little snag I'm not sure how to clear up.

On a main form with a subform I have an unbound combo box. After update the combo box filters the form. Works great. I can select the navigation button on the bottom to unfilter, fine, but if I delete what is in the combo box I get an error. Here is what I have:

Private Sub Combo124_AfterUpdate()
Me.Filter = "ID = " & Me.Combo124
Me.FilterOn = True
End Sub

How do I make the filter false if the combo box is blank?

Thanks and feel free to laugh at my ignorance, really, I don't mind.
 
Just change to this:
Code:
Private Sub Combo124_AfterUpdate()
If Nz(Me.Combo124,vbNullstring)<>vbNullstring Then
    Me.Filter = "ID = " & Me.Combo124
    Me.FilterOn = True
End If
End Sub

And, if you haven't, please rename you control names to something meaningful so the next guy that comes along doesn't have to go nuts trying to go find out what it refers to.
 
Thanks Boblarson. Worked!!! And I will rename it. Once something works I rename it, I don't at first because I delete and retry so many times...(I know! I know! Such an amateur.) 'preciate the help.
 

Users who are viewing this thread

Back
Top Bottom