I am testing a function in the Immediate window. The function uses input from two Inputboxs to select a query and and open a report based on the query selected.
When I test the function using "Second" or "Closing" as the shift input, I receive the following error "The multi-valued field 'tblCostarJobMaster.SchedSequence.Value' in an ORDER BY must also appear in the SELECT list."
Second shift SQL statement
Closing shift SQL statememt
The error is highlighted on the DoCmd.OpenReport code.
Any help with this error would be appreciated.
Code:
strGetShift = InputBox("Enter Shift - First, Second or Closing:")
dtGetDate = InputBox("Enter Schedule Date:")
When I test the function using "Second" or "Closing" as the shift input, I receive the following error "The multi-valued field 'tblCostarJobMaster.SchedSequence.Value' in an ORDER BY must also appear in the SELECT list."
Second shift SQL statement
Code:
'Create a standard second shift schedule from following query:
Case "Second"
strShiftLogSQL = "SELECT tblCostarJobMaster.JobNumber, tblCostarJobMaster.JobName, tblCostarJobMaster.JobNotes, tblCostarJobMaster.SchedSequence.Value " & _
"FROM tblCostarJobMaster LEFT JOIN tblSequence ON tblCostarJobMaster.SchedSequence.Value = tblSequence.SequenceType " & _
"WHERE (((tblCostarJobMaster.JobStatus)=""Active"") " & _
"AND ((tblCostarJobMaster.SchedDay" & intCalcWeekdayNo & ")=True) AND ((tblCostarJobMaster.SchedShift)=""Second"")) " & _
"ORDER BY tblCostarJobMaster.SchedSequence.Value, tblCostarJobMaster.SchedTime;"
Closing shift SQL statememt
Code:
'Create a standard closing schedule from the following query:
Case "Closing"
strShiftLogSQL = "SELECT tblCostarJobMaster.JobNumber, tblCostarJobMaster.JobName, tblCostarJobMaster.JobNotes, tblCostarJobMaster.SchedSequence.Value " & _
"FROM tblCostarJobMaster LEFT JOIN tblSequence ON tblCostarJobMaster.SchedSequence.Value = tblSequence.SequenceType " & _
"WHERE (((tblCostarJobMaster.JobStatus)=""Active"") AND ((tblCostarJobMaster.JobType)=""Closing"")) " & _
"ORDER BY tblCostarJobMaster.SchedSequence.Value, tblCostarJobMaster.SchedTime;"
The error is highlighted on the DoCmd.OpenReport code.
Code:
DoCmd.OpenReport "rptShiftLog", acViewPreview, strShiftLogSQL
Any help with this error would be appreciated.