Solved

Sorting Continuous Forms with Label Click

Posted on 2011-09-19
5
432 Views
Last Modified: 2012-05-12
I have a continuous form that I want to sort by the column (field) when the lable is clicked.  If the field is currently in DESCENDING then I want to reverse the sort when clicked.  If no sort is currently on then sort Ascending.

What is the best way to do this?

me.orderBy or DoCmd.runcommand ascmdsortascending?

0
Comment
Question by:pskeens
5 Comments
 
LVL 21
ID: 36564253
here is an example that does what you want:   Fancy Sort in Continuous Forms
0
 
LVL 75
ID: 36564273
The "easiest way" is to use the built-in right click menus, which include sorting and filtering. No code required.  And better yet, switch to Datasheet view forms, such that besides the right click functionality, you can drag columns next to each other and sort on multiple columns at a time.

mx
Capture1.gif
Capture1.gif
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 36564292
assuming the field you want to sort by is LastName and the the label is LastName_label

private sub LastName_Label_click()
if me.orderby="LastName desc" then
  me.orderby="LastName"
  else
   me.orderby="LastName desc"
end if
me.orderbyon=true

end sub
0
 
LVL 2

Author Comment

by:pskeens
ID: 36662484
I solved it like this:

    If OrderByOn = False Then
           Me.OrderBy = "CARRIER"
    End If
   
    If OrderByOn = True And OrderBy <> "CARRIER" Then
            Me.OrderBy = "CARRIER"
       ElseIf OrderBy = "CARRIER" Then
            Me.OrderBy = "CARRIER DESC"
       ElseIf OrderBy = "CARRIER DESC" Then
            Me.OrderBy = "CARRIER"
      End If
   
            Me.OrderByOn = True
            Me.lbl_carrier.ForeColor = RGB(255, 0, 0)

Thanks Capricorn for pointing me in the right direction!
0
 
LVL 2

Author Closing Comment

by:pskeens
ID: 36662880
Pointed in the right direction but added more functionality to the solution.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now