Dear Old DLookup

  • Thread starter Thread starter DubboPete
  • Start date Start date
D

DubboPete

It must be the most frustrating piece of code in the (Access) world for
those of us with selective memory...

I want to look up a value of a field from a table based on the user's entry
in another field.
Not hard is it?

yeah right.

What's wrong with this?

=DLookUp("password","tblusers","[username] = " &
[Forms]![frmLogin]![username])

thanks and happy St Pat's Oblivion-by-alcohol Day!

StigOfTheDump
 
Pete,

First, the field name to look up must be enclosed in square brackets.
Second, if this is indeed in code, as you imply, then the reference to
the form control for the username (presumably text) must be enclosed in
quotes. Try this:

=DLookUp("[password]","tblusers","[username] = '" &
[Forms]![frmLogin]![username] & "'")

(watch out for wrapping in your newsreader).

P.S. don't feel bad about this, domain aggregate functions take a long
time to digest!

HTH,
Nikos
 
Thanks Nick, but actually... it didn't work!! :-(

but this did...

=DLookUp("[Password]","TblUsers","[Username] =
[Forms]![FrmLogin]![username]")

go figure! :-)
thanks for the help mate

DubboPete
currently in A97 timewarpzone
 
Pete,

It depends on the context... remember I said "if this is indeed in
code"? Your syntax would work in a form, report, query, or macro.
You will figure it out in time, but like I said (also), it takes some
time to digest!

Nikos
 
Nikos,

observe the embedded smileys in my last email ! :-)

It was indeed within a form, as are (99%) most instances of my DLookups....
therefore....

it works...

cheers
Pete
 
Back
Top