Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: why won't date sort by date and not by number or text

Geek News

why won't date sort by date and not by number or text
Gator 11/25/2008 4:23:02 PM
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???

RE: why won't date sort by date and not by number or text
Gator 11/25/2008 4:25:01 PM
Also, the table format is in Date/Time where the datasheet reflects 11/25/08

"Gator" wrote:

[Quoted Text]
> 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???
>
Re: why won't date sort by date and not by number or text
fredg <fgutkind[ at ]example.invalid> 11/25/2008 5:53:08 PM
On Tue, 25 Nov 2008 08:23:02 -0800, Gator wrote:

[Quoted Text]
> 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;
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Re: why won't date sort by date and not by number or text
Gator 11/25/2008 6:03:01 PM
makes good sense...but List15 is blank on List13 click.

"fredg" wrote:

[Quoted Text]
> On Tue, 25 Nov 2008 08:23:02 -0800, Gator wrote:
>
> > 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;
> --
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
>
Re: why won't date sort by date and not by number or text
John Smith <johnDOTsmithATbromleyhospitalsDOTnhsDOTuk> 11/26/2008 4:32:23 PM
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

Gator wrote:
[Quoted Text]
> 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???

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net