ORDEWR BY clause

Softweb

Registered User.
Local time
Today, 10:14
Joined
Feb 12, 2017
Messages
18
[FONT=&quot]Can anyone help with ORDER BY problem please. [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]The following Function resides in an Access 16 Module[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Public Function ShowTrainingHistory(intJobNo As Integer)[/FONT]
[FONT=&quot]Dim strTrainingHistory As String[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] strTrainingHistory = "SELECT Training_date, SubjectToday, Training_ID, Job_No FROM tblSubjectToday WHERE [Job_No]= " & intJobNo[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]'Now assign the Training History of the selected Client to the Training History List on the frmTraining Form.[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Forms("frmClient").[subTraining].Form.lstTrainingHistory.RowSource = strTrainingHistory[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]End Function[/FONT]

The code works fine and populates the ListBox, but I want the List to be ordered by Training_date and I just can’t seem to position a ORDER BY Training_date clause in the string without displaying an error. Any help appreciated :banghead:
:banghead:
 
It should simply go on the end;

Code:
strTrainingHistory = "SELECT Training_date, SubjectToday, Training_ID, Job_No FROM tblSubjectToday WHERE [Job_No]= " & intJobNo & " ORDER BY Training_Date "

What had you tried that failed?
 
Many thanks Minty. I had the ORDER BY clause at the end in quotes but didn't include the space between the clause and its quotes. Really appreciated. Chris
 

Users who are viewing this thread

Back
Top Bottom