Solved

Toggle Sort on a Datasheet sub form

Posted on 2012-04-13
7
542 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server views 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 Access…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…

863 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

25 Experts available now in Live!

Get 1:1 Help Now