Full Version: Orderby Not Working
UtterAccess Forums > Microsoft® Access > Access Forms
Thoreau
Hello,

This should be a simple problem.
I have a continuous form that I want to be able to open sorted by its primary key (Autonumber, long) ascending.
I have the underlying table sorted by the primary key ascending.
I have the "order by" property in the form's property sheet set to the string name of the primary key and the "order by on load" property set to "Yes".
For good measure, I also have the VBA instructions Me.OrderBy = "PK" and Me.OrderByOn = True in the form's OnLoad event.
Nevertheless, the form opens sorted by the primary key in descending order.

Any ideas would be appreciated.
dmhzx
If I want a specific order I normally set it with the query builder from the recordsource 'three dots' button in design view.
Thoreau
Yes, I've tried setting the recordsource to a query based on the table (i.e:

SELECT SET_Order_Items_Services.* FROM SET_Order_Items_Services ORDER BY SET_Order_Items_Services.PK;

but it still orders by the primary key in descending order.
dmhzx
Maybe you need to force it with the Ascending key word?
Thoreau
Unfortunately, when I add "ASC" to the statement it disappears when I save the form.
tiffles17
That's strange... could you possibly post a copy of the db?
theDBguy
Hi,

Welcome to UtterAccess!
welcome2UA.gif
Besides the code you have in the Load event, are there any other codes running on that form?
Thoreau
I also have the code in the form's After_Update event and in a combo box's After_Update event.

I found the following posting to be interesing:

https://social.msdn.microsoft.com/Forums/of...forum=accessdev

also:

http://www.opengatesw.net/forum/smf/genera...derby-settings/
theDBguy
Hmm, there shouldn't really be a need to force it though. Good luck!
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.