Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort Continous form by two critieria

Status
Not open for further replies.

dbar10

Programmer
Dec 5, 2008
196
US
I have a continous form of daily schedule records. It currently lists records by date just fine. But when I have multiple shifts on the same day, I need them to list in order of earliest to latest time. I've been bangin on this for a couple of days and cannot figure out how to get sorted by date and then start time within the same day. Can you help? Below is the query that pulls the records:

SELECT Schedule1.SchedID, Schedule1.WorkerID, Schedule1.AuthID, Schedule1.JobID, Schedule1.Day, Schedule1.Date, Schedule1.Start, Jobs.Job, Schedule1.ProgramID, Schedule1.End, Schedule1.Verified, Schedule1.Cancel, Schedule1.Reason, Schedule1.NoNeed, Schedule1.ClientID
FROM Jobs INNER JOIN Schedule1 ON Jobs.JobID = Schedule1.JobID
WHERE (((Schedule1.Date)>=[Forms]![SchedSearchList]![Clientdatestart] And (Schedule1.Date)<=[Forms]![SchedSearchList]![ClientDateEnd]) AND ((Schedule1.ClientID)=[Forms]![SchedSearchList]![ClientID]));

I am probably overlooking the obvious. But I could sure use your help. Thanks
 
Use an ORDER BY clause in your query.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you for the quick response. I did that but when the records display on the forms only the first set is displayed correctly then the Start time starts shifting down. Like
Sat 12:00AM
Sun 12:00 AM
Mon 8:00 AM
Mon 12: Am
Mon 4:00 PM
Tue 12:00 Am
Tue 8:00 AM
Tue 4:00 PM
Wed 4:00 PM
Wed 12:00 Am
WEd 8:00 Am
Thu 8:00 Am
Thu 4:00 PM
Thu 12:00 AM
and so on....

SELECT Schedule1.SchedID, Schedule1.WorkerID, Schedule1.AuthID, Schedule1.JobID, Schedule1.Day, Schedule1.Date, Schedule1.Start, Jobs.Job, Schedule1.ProgramID, Schedule1.End, Schedule1.Verified, Schedule1.Cancel, Schedule1.Reason, Schedule1.NoNeed, Schedule1.ClientID
FROM Jobs INNER JOIN Schedule1 ON Jobs.JobID = Schedule1.JobID
WHERE (((Schedule1.Date)>=[Forms]![SchedSearchList]![Clientdatestart] And (Schedule1.Date)<=[Forms]![SchedSearchList]![ClientDateEnd]) AND ((Schedule1.ClientID)=[Forms]![SchedSearchList]![ClientID]))
ORDER BY Schedule1.Date, Schedule1.Start;

Any other thoughts?
 
I'm sorry. The correct order should be:

12:00 Am
8:00 Am
4:00 PM
 
Duh!! I just realized the Order by on my form was set to Date and it was overriding the query. When I took that out, it now seems to work fine. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top