John,
Thanks for catching that.  Yes, I did have it that way - deleting
the DESC from the True, but it didn't work that way either (it was a
mistake in the code when I sent it).
Ok, well if the str & " DESC" part looks ok to you, then this should
work.  I'm able to get this to work "ascending" (with the change you
made) but not descending.
I'm surprised that there's not a simpler way to do it, but maybe
that's the best code.
I'll keep playing with it.
... unless there's another way to use the toggle to sort up and down?

Thanks again for your help.
I've been reading this list for a long time and I always enjoy your
responses.

Bill

--- In [email protected], "John Viescas" <[EMAIL PROTECTED]> wrote:
>
> Bill-
>
> Just change Case False to:
>
>    Me.OrderBy = str
>    Me.OrdderByOn = True
>
> John Viescas, author
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> Running Microsoft Access 2000
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
> For the inside scoop on Access 2007, see:
> http://blogs.msdn.com/access/

>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED]
On Behalf
> Of Bill Basile
> Sent: Friday, May 12, 2006 2:15 AM
> To: [email protected]
> Subject: [ms_access] Command button to sort records on a form
>
> Could someone help with this?
>
> It should be really simple -- but I've looked everywhere and I
couldn't
> find it.
> Basically, I'm just looking for a button that can toggle between
sort
> ascending and sort descending on a form.  It can be done with a
right-click
> menu item, so I figured it would be simple code.
>
> I found this in an Access 97 book, but it only works on the
ascending.
>
> Dim str As String, tgl As ToggleButton
> str = "Forms!frmViewAll!lblDESCRIPTION"
> Set tgl = TglDescription
> Select Case tgl.Value
>
> Case True
>      Me.OrderBy = str & " DESC"
>      Me.OrderByOn = True
>
> Case False
>      Me.OrderBy = str & " DESC"
>      Me.OrderByOn = False
>
> End Select
> End Sub
>
> ===============
>
> I think the problem is with the line  Me.OrderBy = str $ " DESC"
>
> The code now will go from unsorted to sort ascending, but it won't
toggle
> to the sort descending.
> Thanks in advance for your help.
>
> Bill
>
>
>
>

> Yahoo! Groups Links
>







YAHOO! GROUPS LINKS




Reply via email to