Sort with Listbox Selection On Top

  • Thread starter Thread starter shmoussa
  • Start date Start date
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
 
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
 
Back
Top