
Originally Posted by
Wayne311
Me.Charge = DLookup("Charge", "Districts", "[District] = '" & Forms(Me.Parent.Name).Controls("CaseNumber Subform1").Form!District & "'")
How would it change for similar data types (both numbers)?
'D' functions only change syntax, as it relates to data types, in the criteria argument. and moreover, working with criteria statements in access, via code or interface is always unnecessarily complex. Don't ask me why, I don't know. The data type that inevitably ends up being thrown into the right side of an operator sign in a criteria statement ALWAYS dictates the format of the quotation and symbol syntax.
the above example, when used with a number, would be:
Code:
Me.Charge = DLookup("Charge", "Districts",
"[District] = " & Forms(Me.Parent.Name).Controls("CaseNumber Subform1").Form!District)
that's called concatenating a value out
you can also concat it in
the difference between doing it IN and OUT is almost strictly related to numbers and dates VS. text.
this is IN:
Code:
"something = '" & textvalueReference & "'"
if you print statements like this out in the immediate window, what you see is this:
something = 'textvalueReference'
this is OUT:
Code:
"something = " & numbervalueReference
if you print statements like this out in the immediate window, what you see is this:
something = numbervalueReference
and this is also OUT:
Code:
"something = #" & datevalueReference & "#"
if you print statements like this out in the immediate window, what you see is this:
something = #datevalueReference#
that's the best I can do.
please please PLEASE read what Allan posted. MVPS has about the simplest explanations that you're going to find on the web. At least those that come from a tutorial-type website. (I don't read their stuff....I only use their freebie services to block annoying advertisements on forums like this.
)