The first one is done when there is no ReceiptDate given, thus it is to return all records:
INSERT INTO zztblDailyReceiptSummary ( dtmReceived, intShiftPaid, intPermitCount, lngReceiptTotal, chrReceiptType, chrReceiptGate, lngPermitNo, lngPermitNo ) SELECT IIf(Len(Trim(Nz([dtmclockout])))>0,Format([dtmclockout],"mm/dd/yyyy"),Format([dtmdayout],"mm/dd/yyyy")) AS receiptdate, tblcampers.intShiftOut, tblcampers.lngPermitNo, tblcampers.curPaidatExit, "Camping" AS Expr1, "Exit" AS Expr2, tblcampers.lngPermitNo, tblcampers.lngPermitNo FROM tblcampers WHERE (((tblcampers.curPaidatExit)>0) AND ((Len(Trim(Nz(IIf(Len(Trim(Nz([dtmclockout])))>0,Format([dtmclockout],"dd"),Format([dtmdayout],"dd"))))))<>0) AND ((tblcampers.blnVoid)=False)) ORDER BY IIf(Len(Trim(Nz([dtmclockout])))>0,Format([dtmclockout],"mm/dd/yyyy"),Format([dtmdayout],"mm/dd/yyyy")), tblcampers.intShiftOut;
This second one is supposed to match the Receipt Date only:
DoCmd.RunSQL "INSERT INTO zztblDailyReceiptSummary ( dtmReceived, intShiftPaid, intPermitCount, lngReceiptTotal, chrReceiptType, chrReceiptGate, lngPermitNo ) " & _ " SELECT IIf(Len(Trim(Nz([dtmclockout])))>0,Format([dtmclockout],'mm/dd/yyyy'),Format([dtmdayin],'mm/dd/yyyy')) AS receiptdate, tblvisitors.intShiftOut, tblvisitors.lngPermitNo, " & _ " tblvisitors.curPaidatExit, 'Visitor' AS Expr1, 'Exit' AS Expr2, tblvisitors.lngPermitNo FROM tblvisitors WHERE (((IIf(Len(Trim(Nz([dtmClockOut]))) > 0, Format([dtmClockOut], 'mm/dd/yyyy'), " & _ " Format([dtmDayIn], 'mm/dd/yyyy'))) = '" & strXDate & "') And ((tblvisitors.curPaidatExit) > 0) And ((Len(Trim(Nz(IIf(Len(Trim(Nz([dtmClockOut]))) > 0, Format([dtmClockOut], 'dd'), Format([dtmDayIn], 'dd')))))) <> 0) And ((tblvisitors.blnVoid) = False)) ORDER BY IIf(Len(Trim(Nz([dtmclockout])))>0,Format([dtmclockout],'mm/dd/yyyy'),Format([dtmdayin],'mm/dd/yyyy')), tblvisitors.intShiftOut;"
SLIGHTLY different queries, but they are both receiving the same error based on the condition of being given a date in the ReceiptDate textbox on the Access Form.
Any help as always is most appreciated!

New Topic/Question
This topic is locked


MultiQuote







|