Toggle Sort on a Datasheet sub form

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?
HKFueyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Dale FyeConnect With a Mentor Commented:
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
 
HKFueyAuthor Commented:
Hi Fyed,
Looks promising but crashes on the last line:
Error 2465 Application Defined or object defined error.
BTW changed 'iff' to 'iif'  ; )
0
 
Dale FyeCommented:
Oops, that should be:

OrderByOn, not OrderOn
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Dale FyeCommented:
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
 
HKFueyAuthor Commented:
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
 
Dale FyeCommented:
I think you selected the wrong answer to give credit to.
0
 
HKFueyAuthor Commented:
Thanks!
0
All Courses

From novice to tech pro — start learning today.