?
Solved

Sorting Continuous Forms with Label Click

Posted on 2011-09-19
5
Medium Priority
?
566 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 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