Sort by two columns in VBA

M

marko

I have made a form with a recordsource and I have sort buttons which
through VBA sort by columns. Now i would like to sort by two columns.
First sort everything by Name and then by Quantity! Is this possible
and how?
I'm using the commands sort ascending and sort descending in VBA.
Thanks,

Marko
 
F

fredg

I have made a form with a recordsource and I have sort buttons which
through VBA sort by columns. Now i would like to sort by two columns.
First sort everything by Name and then by Quantity! Is this possible
and how?
I'm using the commands sort ascending and sort descending in VBA.
Thanks,

Marko

Access sorts records in a left to right order.
Using VBA you would write, in an event on the form:

Me.OrderBy = "[LastName],[Quantity]"
Me.OrderByOn = True


Do you really have a field named "Name"?
Name is a reserved Access/VBA/Jet word and should not be used as a
field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
 
M

marko

No i don't have a field name, i just said that for an example but it
was is supose a bad one.
Thanks for your answer!

Marko
 
M

marko

Yes, i know that i can make a query but i have a lot of command buttons
on that form and i would also like to have that type of advanced
sorting.
 

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

Similar Threads


Top