DLookup

S

Susan

I am using Access 2003. I have two tables connected by CUSTACCT number
(TBL:Entry and TBL:Customer). I would like a form (FRM:Entry) that allows me
to enter CUSTACCT number and then automatically pulls in the CUSTNAME. I have
a query established. I tried using the following expression:

DLookup("CUSTNAME", "TBL:Customer", "[CUSTACCT] =
Form![FRM:Entry]![CUSTACCT]")

This doesn't seem to be working. Any suggestions?
 
D

Douglas J. Steele

Rick Brandt said:
Susan said:
I am using Access 2003. I have two tables connected by CUSTACCT number
(TBL:Entry and TBL:Customer). I would like a form (FRM:Entry) that
allows me to enter CUSTACCT number and then automatically pulls in
the CUSTNAME. I have a query established. I tried using the following
expression:

DLookup("CUSTNAME", "TBL:Customer", "[CUSTACCT] =
Form![FRM:Entry]![CUSTACCT]")

This doesn't seem to be working. Any suggestions?

=Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = " & Me![CUSTACCT])

Or, if CUSTACCT is a text field

=Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = '" & Me![CUSTACCT] & "'")


where, exagerated for clarity, that's

=Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = ' " & Me![CUSTACCT] & " ' ")
 
S

Susan

CUSTACCT is a text field so I used the following expression in my query:
=Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = '" & Me![CUSTACCT] & "'")

Now, when I run the query it gives me:
Enter Paramer value
me!CUSTACCT

If I enter an account number it will pull in that account, but if I bypass
this prompt I get nothing. Am I doing something wrong?


Douglas J. Steele said:
Rick Brandt said:
Susan said:
I am using Access 2003. I have two tables connected by CUSTACCT number
(TBL:Entry and TBL:Customer). I would like a form (FRM:Entry) that
allows me to enter CUSTACCT number and then automatically pulls in
the CUSTNAME. I have a query established. I tried using the following
expression:

DLookup("CUSTNAME", "TBL:Customer", "[CUSTACCT] =
Form![FRM:Entry]![CUSTACCT]")

This doesn't seem to be working. Any suggestions?

=Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = " & Me![CUSTACCT])

Or, if CUSTACCT is a text field

=Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = '" & Me![CUSTACCT] & "'")


where, exagerated for clarity, that's

=Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = ' " & Me![CUSTACCT] & " ' ")
 
D

Douglas J. Steele

Sorry, if you're using this as the control source for a text box, remove the
Me!

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Susan said:
CUSTACCT is a text field so I used the following expression in my query:
=Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = '" & Me![CUSTACCT] & "'")

Now, when I run the query it gives me:
Enter Paramer value
me!CUSTACCT

If I enter an account number it will pull in that account, but if I bypass
this prompt I get nothing. Am I doing something wrong?


Douglas J. Steele said:
Rick Brandt said:
Susan wrote:
I am using Access 2003. I have two tables connected by CUSTACCT number
(TBL:Entry and TBL:Customer). I would like a form (FRM:Entry) that
allows me to enter CUSTACCT number and then automatically pulls in
the CUSTNAME. I have a query established. I tried using the following
expression:

DLookup("CUSTNAME", "TBL:Customer", "[CUSTACCT] =
Form![FRM:Entry]![CUSTACCT]")

This doesn't seem to be working. Any suggestions?

=Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = " & Me![CUSTACCT])

Or, if CUSTACCT is a text field

=Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = '" & Me![CUSTACCT] & "'")


where, exagerated for clarity, that's

=Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = ' " & Me![CUSTACCT] & " '
")
 
R

Rick Brandt

Susan said:
CUSTACCT is a text field so I used the following expression in my
query: =Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = '" &
Me![CUSTACCT] & "'")

Now, when I run the query it gives me:
Enter Paramer value
me!CUSTACCT

If I enter an account number it will pull in that account, but if I
bypass this prompt I get nothing. Am I doing something wrong?

In a query? Your original post said you were doing this on a form. In a
query you would need the full form reference like what you originally had...

Dlookup("CUSTNAME", "Customer", "[CUSTACCT] = '" & Forms!FormName![CUSTACCT]
& "'")

....BUT, you don't really want ot use Domain functions in a query. They
really adversely affect performance when used that way.
 

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