Query will not sort correctly when field is not selected

TomJ58

Registered User.
Local time
Today, 12:28
Joined
Dec 13, 2012
Messages
28
I have created a query that is causing an ordering problem. If I use the following SQL code:


SELECT tblCostarJobMaster.JobNumber, tblCostarJobMaster.JobName, tblCostarJobMaster.JobNotes
FROM tblCostarJobMaster
RIGHT JOIN tblSequence
ON tblCostarJobMaster.SchedSequence.Value = tblSequence.SequenceType
WHERE (((tblCostarJobMaster.JobType)="Closing"))
ORDER BY tblSequence.SequenceNumber, tblCostarJobMaster.SchedTime;


The query will sort correctly by the SequenceNumber field, but not the SchedTime field which holds time in the hh:mm format. However if I include the SchedTime field in the select statement, the query sorts correctly on both fields. Any thoughts on why this is occurring?
 
I know the sort without displaying the time is incorrect because I have writen down the correct order by job number. The recordset is roughly 50 records.
 
The users will not see the raw query. I am building a VBA subroutine with a CASE statement to select one of three queries based on form input. I use the MS Access query design GUI to create a similar query in order to get the SQL statement syntax correct. I am also testing the subroutine by displaying the recordset after I build each case. I noticed the problem after creating the GUI verison of second the query.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom