I have a DLookUp Expression
I use this expression in a form and it works fine.
I it as 'Rate:' in select query "qryLevyPayAll" and it works fine: -
qryLevyPayAll
SELECT tblLevyReceiptsDetail.AutoID, tblLevyReceiptsDetail.Grower, tblLevyReceiptsDetail.Species, tblLevyReceiptsDetail.LevyPaid, tblLevyReceiptsDetail.Tonnes, tblLevyReceiptsDetail.HeaderID, tblLevyReceiptsDetail.LevyYear, tblLevyReceiptsDetail.LevyDate, DLookUp("Rate","tblLevyRates","[LevyYear]= " & [LevyYear] & " And [Species]= '" & [Species] & "'") AS Rate
FROM tblLevyReceiptsDetail
WHERE (((tblLevyReceiptsDetail.LevyDate) Between [Forms]![LevyReportDialog]![DateFrom] And [Forms]![LevyReportDialog]![DateTo]));
Things are going great. BUT!!! When I base select queryB on qryLevyPayAll : -
queryB
I get two error messages.
Now this has me completely stuck.
If the DLookUp is valid on my form and in qryLevyPayAll, why does it misbehave when I refer to the field containing it in queryB?
Code:
=DLookUp("Rate","tblLevyRates","[LevyYear]= " & [LevyYear] & " And [Species]= '" & [Species] & "'")
I use this expression in a form and it works fine.
I it as 'Rate:' in select query "qryLevyPayAll" and it works fine: -
qryLevyPayAll
SELECT tblLevyReceiptsDetail.AutoID, tblLevyReceiptsDetail.Grower, tblLevyReceiptsDetail.Species, tblLevyReceiptsDetail.LevyPaid, tblLevyReceiptsDetail.Tonnes, tblLevyReceiptsDetail.HeaderID, tblLevyReceiptsDetail.LevyYear, tblLevyReceiptsDetail.LevyDate, DLookUp("Rate","tblLevyRates","[LevyYear]= " & [LevyYear] & " And [Species]= '" & [Species] & "'") AS Rate
FROM tblLevyReceiptsDetail
WHERE (((tblLevyReceiptsDetail.LevyDate) Between [Forms]![LevyReportDialog]![DateFrom] And [Forms]![LevyReportDialog]![DateTo]));
Things are going great. BUT!!! When I base select queryB on qryLevyPayAll : -
queryB
Code:
SELECT qryLevyProcXSpp.Name, qryLevyProcXSpp.DateAdded, qryLevyPayAll.Species, qryLevyPayAll.LevyYear, qryLevyPayAll.LevyDate, qryLevyPayAll.Tonnes, [COLOR="Red"]qryLevyPayAll.Rate[/COLOR]
FROM qryLevyProcXSpp LEFT JOIN qryLevyPayAll ON qryLevyProcXSpp.AutoID = qryLevyPayAll.HeaderID
GROUP BY qryLevyProcXSpp.Name, qryLevyProcXSpp.DateAdded, qryLevyPayAll.Species, qryLevyPayAll.LevyYear, qryLevyPayAll.LevyDate, qryLevyPayAll.Tonnes, qryLevyPayAll.Rate;
I get two error messages.
- There is a syntatx error (missing operatro) in the DLookUp in qryLevyPayAll.
- The expression is typed incorrectly or too complex to evaluate.
Now this has me completely stuck.
If the DLookUp is valid on my form and in qryLevyPayAll, why does it misbehave when I refer to the field containing it in queryB?
Last edited: