Sort ascending and descending

P

Pietro

Hi,

I want to sort a fom ascendingly according to the RECEIVED field,what's
the code that i should use in the click event of a button?
I do want to do the same to sort it decendingly..
 
K

KARL DEWEY

Click in the field and then the 'A-Z' icon on the icon bar. Use the 'Z-A' to
sort descending.
 
P

Pietro

Thank you for your reply...
I know this well,i need to crate a button to do this as usually i hide the
main menu bar from my database...
 
K

KARL DEWEY

Ok, one way is to create two queries, one sorting ascending and the other
descending.
Add a new field to each like this ---
Sort_Field: [Forms]![YourFormName]![CheckBox]
In the query for one use a -1 (minus one) as criteria and the other use a 0
(zero).
Put both queries in a union query. Use the union query as source for the
form. In the CheckBox event After Update have it requery. Label it 'Sort
Ascending' so when checked it will be a -1.

Only one of the first two queries will pull records to output from the union.
 
F

fredg

Hi,

I want to sort a fom ascendingly according to the RECEIVED field,what's
the code that i should use in the click event of a button?
I do want to do the same to sort it decendingly..

Code the command button's Click event:
If Me.OrderBy = "Receiving" Then
Me.OrderBy = "Receiving Desc"
Me.OrderByOn = True
Else
Me.OrderBy = "Receiving"
Me.OrderByOn = True
End If
 

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