Filter Alphabetically using VBA

runnerup

New member
Local time
Yesterday, 23:29
Joined
Sep 5, 2007
Messages
1
I have a form that displays client names and information, with a subform that contains invoices pertaining to that client. The underlying tables are joined on client number.

The list of clients is getting unweildy, so I wish to add 26 buttons, one representing each letter of the alphabet, to either GoTo or Filter for that specific letter. I'd prefer to not have to write a SELECT query for each letter. So far, I have been using variations on the following:


Private Sub GoToH_Click()

DoCmd.OpenForm "Data Entry", , , Left(Me.ClientName, 1) = "H"

End Sub


I have also tried


Private Sub GoToL_Click()

DoCmd.OpenForm "Data Entry", , , Me.ClientName Like "L*"

End Sub


Sometimes the event will filter no Client records at all, and sometimes it will filter away all Clients. Every time, however, it filters away all of the invoice records (in the subform).

I am new to VBA, but I do have extensive (aka "overwhelming") reference material. I have invested several hours in this, and I'm still scratching my head.

Thanks,


--Rob
 
This has been discussed before in this forum. There is even a sample in the SAmple Databases area.
 
I know this has been discussed before, but it seems to me that you'd want to use a combo box instead of using 26 buttons?
 
One of the sample DBs supplied by Access has an example of something very similar
 

Users who are viewing this thread

Back
Top Bottom