Full Version: Combo box that has "All"
UtterAccess Forums > Microsoft® Access > Access Forms
jmk909er
I have a combo box on a form that uses a query to select records by name and it works fine. I also have a button next to it that sets the Me.FilterOn = False so that all the records show again after looking by name. Is there any way to put "All" in the combo box so that I can eliminate the filter button?
Thanks, Joe
LPurvis
Well, part of the problem is that, once the combo box has all - what do you buy for it as a gift? :-p
Sorry - I felt compelled to make that awful pun. And so now am pretty much obligated to answering the question.
If you make your RowSource:
SELECT TOP 1 "ALL", 0 FROM qryPM UNION ALL SELECT PM, 1 FROM qryPM ORDER BY 2, 1
Then you'll see the rows you want.
You'll then just need to change your code a little.
CODE
Private Sub Combo22_AfterUpdate()
    If Me.Combo22 = "All" Then
        Me.FilterOn = False
    Else
        Me.Filter = "PM = '" & Me.Combo22 & "'"
        Me.FilterOn = True
    End If
End Sub

It's better pratice to give your controls meaningful names though. (Combo22 tells you nothing about its purpose.)
Cheers
jmk909er
Hey LPurvis, Thank you so much. I applied what you gave me and it is working like a champ, and thanks for the humor! I don't get it but thanks.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.