Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Toggle Sort on a Datasheet sub form

Posted on 2012-04-13
7
Medium Priority
?
557 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
[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
  • 4
  • 3
7 Comments
 
LVL 48

Accepted Solution

by:
Dale Fye earned 2000 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 48

Expert Comment

by:Dale Fye
ID: 37842235
Oops, that should be:

OrderByOn, not OrderOn
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 48

Expert Comment

by:Dale Fye
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 48

Expert Comment

by:Dale Fye
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

636 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