why won't date sort by date and not by number or text

G

Gator

the date referenced below in code is sorting like....
September08
September07
October08
October07

instead of.....
October08
September08
October07
September07

Private Sub List13_Click()

List15.RowSource = "SELECT Format((DateDep),'mmmmyy'),
Format(SUM(Amount),'currency'), Account
FROM Deposits
WHERE (Account='" & List13 & "')
GROUP BY Format((DateDep),'mmmmyy'), Account
ORDER BY Format((DateDep),'mmmmyy') DESC;"

End Sub

I want it to sort by date and not like a string text or number....any ideas???
 
F

fredg

the date referenced below in code is sorting like....
September08
September07
October08
October07

instead of.....
October08
September08
October07
September07

Private Sub List13_Click()

List15.RowSource = "SELECT Format((DateDep),'mmmmyy'),
Format(SUM(Amount),'currency'), Account
FROM Deposits
WHERE (Account='" & List13 & "')
GROUP BY Format((DateDep),'mmmmyy'), Account
ORDER BY Format((DateDep),'mmmmyy') DESC;"

End Sub

I want it to sort by date and not like a string text or number....any ideas???

ORDER BY DateDep DESC;
 
J

John Smith

When you format the date you are converting it to text so it sorts
alphabetically. To do what you want add another column to sort by and set
it's width in the list box to zero so that it cannot be seen:

List15.RowSource = "SELECT Format(DateDep,'yyyymm'),
Format(DateDep,'mmmm yy'), Format(SUM(Amount),'currency'), Account
FROM Deposits
WHERE Account='" & List13 & "'
GROUP BY Format(DateDep,'yyyymm'), Format(DateDep,'mmmm yy'), Account
ORDER BY Format(DateDep,'yyyymm') DESC"

HTH
John
##################################
Don't Print - Save trees
 

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