Solved

Toggle Sort on a Datasheet sub form

Posted on 2012-04-13
7
546 Views
Last Modified: 2012-04-13
I have a datasheet sub form (embedded in a pop up form) and want to toggle the sort of one column from a button on the main form, can anyone help with syntax?
0
Comment
Question by:HKFuey
  • 4
  • 3
7 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 37841920
Private sub cmd_Sort_Click

    dim strOrderBy as string

    strOrderBy = me.subformcontrolname.form.orderBy

   strOrderBy = "[FieldName]" &  Iff(instr(strOrderBy, "DESC") =0, " DESC", NULL)

   me.subformcontrolname.Form.OrderBy = strOrderBy
   me.subformcontrolname.Form.OrderOn = true

ENd Sub

Note: you must replace "subformcontrolname" with the name of the subform control as it is seen in the Name property when viewing the main form in design view.  Do not confuse this with the subform's sourceobject.
0
 

Author Comment

by:HKFuey
ID: 37842203
Hi Fyed,
Looks promising but crashes on the last line:
Error 2465 Application Defined or object defined error.
BTW changed 'iff' to 'iif'  ; )
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37842235
Oops, that should be:

OrderByOn, not OrderOn
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37842242
Hey,

It's early, and I hadn't had my coffee yet.  And what good is a programmer who hasn't had his/her first cup of coffee?
0
 

Author Comment

by:HKFuey
ID: 37843451
I've requested that this question be closed as follows:

Accepted answer: 0 points for HKFuey's comment #37842203

for the following reason:

Works perfectly, thanks very much!
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37843452
I think you selected the wrong answer to give credit to.
0
 

Author Closing Comment

by:HKFuey
ID: 37843474
Thanks!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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…

808 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