Forum Discussion
#Error in Query (nulls?)
- Sep 14, 2023
Hi Tony,
> the format is short text for both of those fields.
Ok, then I misunderstood your description. I thought you were getting the error only for some records. With this information it is clear that you should get the error for every record because the syntax for text is different than for numbers. You have to put the text parameter in quotation marks:
WDDateGetError: DLookUp("MaxOfWithdrawalDate","qryWDDate","Reference = '" & [Invoice No] & "'"
[edited after XPS35 spotted the wrong column/field name]
Servus
Karl
****************
Access Forever
Access News
Access DevCon
Access-Entwickler-Konferenz AEK
Hi,
The error can have several causes. You shouldn't get it because of Nulls in Reference but maybe because of Nulls in [Invoice No]. To avoid that, you can try this
WDDateGetError: iif(Not IsNull([Invoice No]), DLookUp("[WithdrawalDate]","qryWDDate","[Reference] = " & [Invoice No]))
Servus
Karl
****************
Access Bug Trackers
Access News
Access DevCon
Access-Entwickler-Konferenz AEK
- Tony2021Sep 13, 2023Steel Contributor
Hi Karl, thank you for the response. I thought for certain that would be the solution but unfortunately, I still get the =#error. I confirm I do have nulls on [Invoice No] and [Reference].
the format is short text for both of those fields.
let me know what is the next step. thank you!
If it makes a difference, the query is as follows: (its a grouped query and a max on [WithdrawalDate])
SELECT tblPmtProposalALL.ID2, tblPmtProposalALL.DDNo, tblPmtProposalALL.Reference, tblPmtProposalALL.Amount, Max(tblDraws_CAWC.WithdrawalDate) AS MaxOfWithdrawalDate
FROM (tblDraws INNER JOIN (tblCompanies INNER JOIN tblPmtProposalALL ON tblCompanies.CoID = tblPmtProposalALL.ID2) ON tblDraws.ID = tblPmtProposalALL.DrawIDfk) INNER JOIN tblDraws_CAWC ON tblDraws.ID = tblDraws_CAWC.IDDraws
GROUP BY tblPmtProposalALL.ID2, tblPmtProposalALL.DDNo, tblPmtProposalALL.Reference, tblPmtProposalALL.Amount
ORDER BY tblPmtProposalALL.DDNo;- XPS35Sep 14, 2023Iron ContributorYou do a lookup on WithdrawalDate, but in the query that field is renamed to MaxOfWithdrawalDate. Maybe that is (one of) the problem(s).
- Sep 14, 2023
Hi Tony,
> the format is short text for both of those fields.
Ok, then I misunderstood your description. I thought you were getting the error only for some records. With this information it is clear that you should get the error for every record because the syntax for text is different than for numbers. You have to put the text parameter in quotation marks:
WDDateGetError: DLookUp("MaxOfWithdrawalDate","qryWDDate","Reference = '" & [Invoice No] & "'"
[edited after XPS35 spotted the wrong column/field name]
Servus
Karl
****************
Access Forever
Access News
Access DevCon
Access-Entwickler-Konferenz AEK- Tony2021Sep 15, 2023Steel ContributorHi Karl, that worked perfectly. thanks for pointing out that its TEXT so have to change it up a little. I forgot that text is different. thanks again for pointing out the name also needed to be changed to MaxOfWithdrawalDate (thank you XPS35). I did notice that early on but thought it was not my issue since I didnt realize I also needed to account for the field being TEXT. have a good weekend! thanks for the help guys!