Link to home
Start Free TrialLog in
Avatar of Tetsinger
Tetsinger

asked on

Need sort ascending visual basic code.

Sub form data, that is retrieving data from a query will not sort according to set query properties.  I seem to need to force the sort on the subform as it is being accessed using visual basic.  I need a sort ascending line of visual basic code, unless there is another way.
Thanks
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Hi Tetsinger,

You'll need to use your subform's Order By property to sort within the subform.  

One trick I do all the time is to have toggle buttons that look like column headers in my button.  Push the button down, your subform sorts A-Z by that field by editing the OrderByOn property.  Push it again, it sorts Z-A.  Let me know if you'd like the code.

Hope this helps.
-Jim
Avatar of Tetsinger
Tetsinger

ASKER

Greetings:
I had already set the subform's property to sort withing the subform.  But when I bring up the database from a fresh start up, the subform data is still not sorted.  I'm not sure what you're getting at in your second paragraph.  

I thought if I just put in a couple simple lines of code to directly sort the subform data I could override whatever is causing it to be out of sorts (so to speak).  For example, this is where I was heading:
     DoCmd.GoToControl "gpsbx"
     DoCmd.DoMenuItem acFormBar, acRecordsMenu, ??, , acMenuVer70

However I can't get the ?? part of the code right.

I found this property setting below, but do not know how to implement it or if it is appropriate.

acCmdSortAscending

Do you have another idea?
ASKER CERTIFIED SOLUTION
Avatar of shanesuebsahakarn
shanesuebsahakarn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
(which is what Jim was getting at)