dlookup with textbox on report

  • Thread starter Thread starter tonyrulesyall
  • Start date Start date
T

tonyrulesyall

I would like to reference a textbox on a current report with
a dlookup like this:

=DLookUp("dob","tblmain",[fileno]=[me!txtFile])
but it gives me a #name error.

What should be done differently?
 
Try:
=DLookUp("dob","tblmain","[fileno] = " & [me!txtFile])

That assumes that fileno is a numeric datatype; if it's text, you'll need
single-quote delimiters, thus:
=DLookUp("dob","tblmain","[fileno] = '" & [me!txtFile] & "'")

Expanded for clarity, that's
=DLookUp("dob","tblmain","[fileno] = ' " & [me!txtFile] & " ' ")

And finally, if fileno may contain a single-quote (or apostrophe) character,
use a pair of double-quote characters instead of the single-quote
characters.

HTH,

Rob
 
I would like to reference a textbox on a current report with
a dlookup like this:

=DLookUp("dob","tblmain",[fileno]=[me!txtFile])
but it gives me a #name error.

What should be done differently?

1) Your criteria brackets .... [me!txtFile] .... are placed
incorrectly. it should be me![txtFile].
2) Each argument must be a string. You omitted the quotes in the where
clause argument.
3) The criteria value should be concatenated into the where clause
expression.

=DLookUp("dob","tblmain","[fileno]= " & me![txtFile])

The above assumes [fileno] is a number datatype.
 
Back
Top