Yes it does matter.
First I would probably declare SVID as a LONG and not an integer since
the largest integer is 64K in size.
If SVID is a variant then you could have a problem is you didn't
populate it with some value.
If SVID is a string then you should not have a problem (unless you fail
to assign it a value).
If Service Volume ID is a number then you have a valid statement.
If Service Volume ID is a string then you need to include quote marks
around the SVID when you use it in the expression.
SiteID = NZ(DLookup("[ID]", "SiteTBL", "[Service Volume ID] = """ & SVID
& """"),0)
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
Yes, SVID is a variable in my code.
In your example, does it matter if SVID is a Variant, Integer or String?
You mean SVID is simply a variable in your code, as opposed to a
control on
your form?
SiteID = DLookup("[ID]", "SiteTBL", "[Service Volume ID] = "& SVID)
Note that this will only work if SiteID is defined as a Variant, since
DLookup will return Null if it cannot find a record corresponding to the
SVID value provided and Variants are the only data type that can hold
Null
values. If you'd settle for having a SiteID of 0 if one isn't found, you
could declare SiteID as a specific type (Integer or Long), and then use
SiteID = Nz(DLookup("[ID]", "SiteTBL", "[Service Volume ID] = "&
SVID), 0)