thanks I have now put the sql in place
but still getting error run time 424 object required
here the code now
thanks
shane
but still getting error run time 424 object required
here the code now
Code:
Private Sub Command77_Click()
Dim strSQL As String
strSQL = "SELECT tblemployee.employeeId, tblExposure.Dateexposure, [Valuef/cm]*[Durationofexposure] AS [Total Ex], tblemployee.firstname, tblemployee.lastname " & _
" FROM tblExposure " & _
" INNER JOIN tblemployee ON tblExposure.ID = tblemployee.ID "
If Not IsNull(Me.employeeId) Then
strWhere = strWhere & "([employeeId] = " & Me.employeeId & ") AND "
End If
lngLen = Len(strWhere) - 5
DoCmd.Hourglass True
If lngLen <= 0 Then
strSQL = strSQL
Set qryDef = dbs.CreateQueryDef("Exposure Grapth1", strSQL)
qryDef.Close
Set qryDef = Nothing
DoEvents
SaveQueriesToExcel "C:\Users\Dell\Documents\Exposure Grapth - Copy.xlsm", "Exposure Grapth1"
DoEvents
DoCmd.DeleteObject acQuery, "Exposure Grapth1"
Else
strWhere = Left$(strWhere, lngLen)
strSQL = strSQL & " WHERE " & strWhere
[COLOR=red][B] Set qryDef = dbs.CreateQueryDef("Exposure Graph1", strSQL)[/B][/COLOR]
qryDef.Close
Set qryDef = Nothing
DoEvents
SaveQueriesToExcel "C:\Users\Dell\Documents\Exposure Grapth - Copy.xlsm", "Exposure Grapth1"
DoEvents
DoCmd.DeleteObject acQuery, "Exposure Graph1"
End If
DoCmd.Hourglass False
DoCmd.CancelEvent
End Sub
thanks
shane