Solved

Toggle Sort on a Datasheet sub form

Posted on 2012-04-13
7
538 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

707 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

14 Experts available now in Live!

Get 1:1 Help Now