dlookup with textbox on report

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?
 
R

Rob Parker

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
 
F

fredg

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top