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
 
M

Marshall Barton

shmoussa said:
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.

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
 
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
 
M

Marshall Barton

shmoussa said:
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?


VBA code never, ever goes in an SQL statement. VBA code can
ONLY go in a module, In your case I suggest that you put it
in a button's click event (the button is for users to say
the list box selection is made and they are ready to do the
search). If you want to do the search immediately when a
row is selected in the list box, then you can put the code
in the list box's AfterUpdate event procedure.
 
T

tom_willpa

high quality Soccer jerseys NBA Jersey tracksuit and jackets, GHD
hairstraightener supplier from www.willpa.com

Are you a Retail businessman who bother by the purchase price? China
Cheapest TOP wholesale website can help you

we are specialize in replica sport goods manufacturing in china, we can
offer you all kinds of soccer jersey, NBA jersey,shoes and so on. they are
the best brand replica goods whih are look the same as the original goods.
excellent quality and steady supply for them. we have been marketed in Europe
and American for 3 year. all the goods we offer are AAA quality. our soccer
jersey are Thailand style. If any goods you buy from my company have problem,
we will refund or resend them again. Most of ourProducts have no minimum
order requirements,soyou can shop retail goods at wholesale prices. if you
can buy more than 300usd. We offer free shipping. The more you buy the more
discount for you.

National soccer jerseys: http://www.willpa.com
Club soccer jerseys: http://www.willpa.com
NBA Jerseys: http://www.willpa.com
T-shirt and shirt: http://www.willpa.com
Tracksuit: http://www.willpa.com
Hoody & Jackets: http://www.willpa.com
UGG boots: http://www.willpa.com
Hair style: http://www.willpa.com
shopping Index: http://www.willpa.com

EMS shipping. 7days arrive, paypal accept

want more information pls contact us or check our website: www.willpa.com
 

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