Solved

Sorting Continuous Forms with Label Click

Posted on 2011-09-19
5
503 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 120

Accepted Solution

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Empty Record being created 4 42
Check a field in Access on a Timer 1 28
Weird Microsoft Access Error 8 40
add dollar amount in VB code, Access 2003 6 11
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

679 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