Solved

Sorting Continuous Forms with Label Click

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

732 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