L
Little Daddy
When this code executes it generates error 2001 "you canceled the previous
operation" right after the DoCmd.OpenQuery and doesn't open the actual query.
If the HAVING statement is modified not have the OR operator it will work.
strSQLTemp2 = "SELECT First(PartNum) AS FirstOfPartNum, SerialNum,
First(PartDesc) AS FirstOfPartDesc, First(EmpNum) AS FirstOfEmpNum,
First(EntryDate) AS FirstOfEntryDate, First(Pass_Fail) AS FirstOfPass_Fail
FROM tblTestLog " _
& "GROUP BY SerialNum " _
& "HAVING (((First(PartNum)) Like '" & strPNum _
& "' AND " & "(First(Pass_Fail)) Like '" & strPass_Fail _
& "' AND " & "(SerialNum)<> '" & "0" _
& "' AND " & "(First(EntryDate)) Between " & "#" & dteStart & "#" &
" AND " & "#" & dteStop & "#)" & " Or " & "((First(PartNum)) Like '" &
strPNum _
& "' AND " & "(First(Pass_Fail)) Like '" & strPass_Fail _
& "' AND " & "(First(EmpNum))<> '" & 0 _
& "' AND " & "(First(EntryDate)) Between " & "#" & dteStart & "#" &
" AND " & "#" & dteStop & "#))"
strSQL = strSQLTemp2
Set dbs = CurrentDb()
Set qdef = dbs.CreateQueryDef("qryPassTable", strSQL)
DoCmd.OpenQuery "qryPassTable", acNormal, acReadOnly
Thanks
Little Daddy
operation" right after the DoCmd.OpenQuery and doesn't open the actual query.
If the HAVING statement is modified not have the OR operator it will work.
strSQLTemp2 = "SELECT First(PartNum) AS FirstOfPartNum, SerialNum,
First(PartDesc) AS FirstOfPartDesc, First(EmpNum) AS FirstOfEmpNum,
First(EntryDate) AS FirstOfEntryDate, First(Pass_Fail) AS FirstOfPass_Fail
FROM tblTestLog " _
& "GROUP BY SerialNum " _
& "HAVING (((First(PartNum)) Like '" & strPNum _
& "' AND " & "(First(Pass_Fail)) Like '" & strPass_Fail _
& "' AND " & "(SerialNum)<> '" & "0" _
& "' AND " & "(First(EntryDate)) Between " & "#" & dteStart & "#" &
" AND " & "#" & dteStop & "#)" & " Or " & "((First(PartNum)) Like '" &
strPNum _
& "' AND " & "(First(Pass_Fail)) Like '" & strPass_Fail _
& "' AND " & "(First(EmpNum))<> '" & 0 _
& "' AND " & "(First(EntryDate)) Between " & "#" & dteStart & "#" &
" AND " & "#" & dteStop & "#))"
strSQL = strSQLTemp2
Set dbs = CurrentDb()
Set qdef = dbs.CreateQueryDef("qryPassTable", strSQL)
DoCmd.OpenQuery "qryPassTable", acNormal, acReadOnly
Thanks
Little Daddy