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
TetsingerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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
0
TetsingerAuthor Commented:
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?
0
shanesuebsahakarnCommented:
Forms!MyMainForm!MySubformControlName.Form.OrderBy="[MyField]"
Forms!MyMainForm!MySubformControlName.Form.OrderByOn=True

Ensure that MySubformControlName is the name of the subform control and not the subform itself (design the main form, click once on the subform and check its Name property in the properties window).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shanesuebsahakarnCommented:
(which is what Jim was getting at)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.