Stuttering Loads (1 Viewer)

MatthewB

Member
Local time
Today, 06:17
Joined
Mar 30, 2022
Messages
85
I have a continuous form. I put: DoCmd.SetOrderBy "[StrataPlanNr],[ServiceLines]"
to sort the form when it loads.
There is something wrong with this code.

Q1: What?
Q2: Is there a depository of documentation from Microsoft or others about the syntax for such statements?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:17
Joined
Feb 19, 2002
Messages
43,302
If you want to order the data, put the order by in your query.
 

isladogs

MVP / VIP
Local time
Today, 14:17
Joined
Jan 14, 2017
Messages
18,240
Or you can use the form property sheet to sort the data if you prefer

1655654712837.png
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:17
Joined
Feb 19, 2002
Messages
43,302
If the form's Orderby runs AFTER the form is loaded, then Access has to process the RecordSource twice. Therefore, sorting in the RecordSource query saves a step. If you want to sort on command later, then use the OrderBy property.
 

MatthewB

Member
Local time
Today, 06:17
Joined
Mar 30, 2022
Messages
85
I am using a foreign key to set a field that is part of the ordering. As it is a number I am guessing it is sorting numerically (the kp value). What would I need to do to make this sort alphabetically?
Thanks
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:17
Joined
Feb 28, 2001
Messages
27,194
If there is a text field associated with the FK, you would write a SELECT query to JOIN the table you wanted sorted with the table that contains the translation of that foreign key. Then you would sort the query on the text field that you brought in using the JOIN.

Code:
SELECT A.F, A.G, A.H, B.HName FROM A INNER JOIN B on A.H = B.H .... (if you had a WHERE clause, it would go here) ... ORDER BY B.HName;
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:17
Joined
Sep 21, 2011
Messages
14,320
I am using a foreign key to set a field that is part of the ordering. As it is a number I am guessing it is sorting numerically (the kp value). What would I need to do to make this sort alphabetically?
Thanks
If you make it sort alphabetically by making a string, then it would not sort as you think it should? :(
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:17
Joined
Feb 19, 2002
Messages
43,302
Gasman, I think the question was about sorting by the text field rather than the ID field.

@MatthewB If you are using a table level lookup, you should consider removing it. They are a crutch for people who don't know how to write a query with a join. They also obfuscate the data. You look at it and you see text but you sort and the sort is on the hidden ID. I don't think that is user friendly. And it is only one of the many problems you encounter.
 

Users who are viewing this thread

Top Bottom