Sort with Listbox Selection On Top

S

shmoussa

Hi,

I have a listbox. When I select an item in the listbox, I would like
subform1 to sort column1 with the selection from listbox on top.

For example, when I select Pennsylvania from the listbox- it will
update subform1 to, while still retaining all of the records, but all
records with "Pennsylvania" listed in column1 on top.

Is this possible? Thanks
 
S

shmoussa

That's not a sort problem.  Presumably the records are
already sorted by state so all you need to do is navigate to
the first record with the selected state:

With Me.subform1.Form.Recordset
        .FindFirst "statefield = '" & Me.thelistbox & "' "
        If .Nomatch Then Beep
End With


Thanks for the reply. Can you tell me where to put this? Does it go in
the SQL for the query that generates the subform? Or in VBA for which
event?

Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top