Jul 12 2005, 01:45 PM
Is there a certain way to use ORDER BY in a subform? I have tried entering the name of the field that I want to ORDER BY in the main form, subform, Form!MainForm!Field, Form!Main!Subform!Field, etc. and I cannot get it to work. The field I want to Order is located in the subform. It does not matter if the main form is ordered or not. Is there any solution to this problem?
Jul 12 2005, 02:00 PM
This is how I would do it but it's just what I experience.
Go to the recordsource property for the subform and enter your cursor in the recordsource property field perhaps after the table/query name.
Note the epillipse (...) that appears to the right of the recordsource property, and click on it, you may get a message prompt, click ok and a query grid will open up.
Sort on the desired field as required.
Close the query and click yes at the prompt to save the SQL changes.
Now immediately save the form using the save icon or file>save or you will lose the SQL changes you just made.
Now your subform should be sorted.
Jul 12 2005, 02:09 PM
Thanks for the help. I wonder why it works with the query and not the ORDER BY property? Oh Well, I appreciate your help.
Jul 12 2005, 02:34 PM
Its a strange one. I found another webpost on the issue which says.....
You have to define the orderby of the sub-form in the main form.
Set the OrderBy (and set OrderByOn to true) for the subform in the
OnOpen or OnCurrent event of the main form. Something like:
Me![name of subform control].form.OrderBy = "field you want to sort on"
Me![name of subform control].form.OrderByOn = True
But I have no experience of using this - just might be interesting for you to check it out.
Jul 12 2005, 03:04 PM
Jul 12 2005, 03:12 PM
Glad to help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here