[AccessD] Numbers in DLookup

Bob Heygood bheygood at abestsystems.com
Mon Mar 20 15:27:19 CST 2006


Sure enough, the brackets make the difference.

Works:  varData = Nz(DLookup("[" & strFieldName & "]", strTableName, "CoID
=" & intCoID))

No Work:  varData = Nz(DLookup(strFieldName, strTableName, "CoID =" &
intCoID))


Thanks Charlotte

bob




Put the value with numbers at the front in square brackets, same as you
would for a name with a space in it, and see if that makes a difference.



Charlotte Foust


Hello to the list!
I am trying to use a DLookup function in some code.
It uses two string variable values for the Expr and the Domain arguments.
And a third string variable for the part of the Where clause.

This works fine until the value of the Expr string contains digits anywhere
but at the end of the string. Hard to believe, but when I remove the records
from the table from which I derive the string, works fine. But if I leave in
those records that contain a one or more digits except at the end, it give
the error message:

Syntax error(missing operator) in query expression '2004TotalTurnoverED207'.

Sure enough, 2004TotalTurnoverED207 is the correct value.
Other values such as TotalHours, TotalMan201 and AveUnits45 all work fine in
the DLookup as values for the Expr, just not when the digits occur anywhere
but at the end of the string.

Any help would prevent further head banging.

TIA

bob





More information about the AccessD mailing list