I have used the following code in a command button, on a form, to build a query:
Question 1 - The above works if I select a staff member from combo box (cmbStaff), but does not if I don't.
How can I get to work with a null entry?
Question 2 - The table (HourEnter) has a field (Hours_Worked) and the query lists all the hours, line by line for the selected job number in cmbJobList. How can I get the sum of all the hours for selected job number, in the combobx (cmbJobList), in one line?
Thanks Sandy
Code:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("JobSummaryQuery")
strSQL = "SELECT tblHourEnter.* " & _
"FROM tblHourEnter " & _
"WHERE tblHourEnter.JobNumber=" & Me.cmbJobList.Value & " " & _
"AND tblHourEnter.Staff_ID=" & Me.cmbStaff.Value & " " & _
"ORDER BY tblHourEnter.JobNumber;"
qdf.SQL = strSQL
DoCmd.OpenQuery "JobSummaryQuery"
' DoCmd.Close acForm, Me.Name
Set qdf = Nothing
Set db = Nothing
How can I get to work with a null entry?
Question 2 - The table (HourEnter) has a field (Hours_Worked) and the query lists all the hours, line by line for the selected job number in cmbJobList. How can I get the sum of all the hours for selected job number, in the combobx (cmbJobList), in one line?
Thanks Sandy