Need sort ascending visual basic code.

Posted on 2005-03-31
Medium Priority
Last Modified: 2013-11-25
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.
Question by:Tetsinger
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
  • 2
LVL 66

Expert Comment

by:Jim Horn
ID: 13674928
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.

Author Comment

ID: 13676073
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.


Do you have another idea?
LVL 41

Accepted Solution

shanesuebsahakarn earned 500 total points
ID: 13678418

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).
LVL 41

Expert Comment

ID: 13678421
(which is what Jim was getting at)

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

765 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