By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

DLookup questions

P: n/a
JLM
What am I missing here?

I have a form where I enter a "Class Code". This value corresponds to what
sits in table "class code descriptions" along with the "title" of each
"class code." Key field is "class code."

I want a text box to be populated with the "title" which corresponds to the
"class code" which I enter in the form. The control source for the text box
is:

=DLookUp("[Title]","[class code descriptions]","[CCode] = forms![CCode]")
[this is literally what I have in the control source for the field.]

I get no value returned when I know that there is are corresponding values
in the table.

What am I missing here?

thanks in advance,
jlm
Nov 12 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Wed, 18 Feb 2004 11:03:42 -0700, JLM wrote:
What am I missing here?

I have a form where I enter a "Class Code". This value corresponds to what
sits in table "class code descriptions" along with the "title" of each
"class code." Key field is "class code."

I want a text box to be populated with the "title" which corresponds to the
"class code" which I enter in the form. The control source for the text box
is:

=DLookUp("[Title]","[class code descriptions]","[CCode] = forms![CCode]")
[this is literally what I have in the control source for the field.]

I get no value returned when I know that there is are corresponding values
in the table.

What am I missing here?

thanks in advance,
jlm


Re: > Key field is "class code."
Is the Key Field "Class Code" or is it "CCode"?
If the field is actually named "CCode" and it is a Number Datatype,
then:

=DLookUp("[Title]","[class code descriptions]","[CCode] = " &
Me![CCode])

where [CCode] is the name of the control on the form that shows the
number to look up.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 12 '05 #2

P: n/a
JLM

"fredg" <fg******@att.net> wrote in message
news:tj****************************@40tude.net...
On Wed, 18 Feb 2004 11:03:42 -0700, JLM wrote:
What am I missing here?

I have a form where I enter a "Class Code". This value corresponds to what sits in table "class code descriptions" along with the "title" of each
"class code." Key field is "class code."

I want a text box to be populated with the "title" which corresponds to the "class code" which I enter in the form. The control source for the text box is:

=DLookUp("[Title]","[class code descriptions]","[CCode] = forms![CCode]") [this is literally what I have in the control source for the field.]

I get no value returned when I know that there is are corresponding values in the table.

What am I missing here?

thanks in advance,
jlm


Re: > Key field is "class code."
Is the Key Field "Class Code" or is it "CCode"?
If the field is actually named "CCode" and it is a Number Datatype,
then:

=DLookUp("[Title]","[class code descriptions]","[CCode] = " &
Me![CCode])

where [CCode] is the name of the control on the form that shows the
number to look up.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.


Key field is actually CCode and is text.
Nov 12 '05 #3

P: n/a
On Wed, 18 Feb 2004 11:57:27 -0700, JLM wrote:
"fredg" <fg******@att.net> wrote in message
news:tj****************************@40tude.net...
On Wed, 18 Feb 2004 11:03:42 -0700, JLM wrote:
What am I missing here?

I have a form where I enter a "Class Code". This value corresponds to what sits in table "class code descriptions" along with the "title" of each
"class code." Key field is "class code."

I want a text box to be populated with the "title" which corresponds to the "class code" which I enter in the form. The control source for the text box is:

=DLookUp("[Title]","[class code descriptions]","[CCode] = forms![CCode]") [this is literally what I have in the control source for the field.]

I get no value returned when I know that there is are corresponding values in the table.

What am I missing here?

thanks in advance,
jlm


Re: > Key field is "class code."
Is the Key Field "Class Code" or is it "CCode"?
If the field is actually named "CCode" and it is a Number Datatype,
then:

=DLookUp("[Title]","[class code descriptions]","[CCode] = " &
Me![CCode])

where [CCode] is the name of the control on the form that shows the
number to look up.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.


Key field is actually CCode and is text.

Then use:
=DLookUp("[Title]","[class code descriptions]","[CCode] = '" &
Me![CCode]) & "'")

With spaces addedd for clarity, the Where clause is:
"[CCode] = ' " & Me![CCode]) & " ' ")
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 12 '05 #4

P: n/a
JLM

"fredg" <fg******@att.net> wrote in message
news:mw***************************@40tude.net...
On Wed, 18 Feb 2004 11:57:27 -0700, JLM wrote:
"fredg" <fg******@att.net> wrote in message
news:tj****************************@40tude.net...
On Wed, 18 Feb 2004 11:03:42 -0700, JLM wrote:

What am I missing here?

I have a form where I enter a "Class Code". This value corresponds to

what
sits in table "class code descriptions" along with the "title" of each
"class code." Key field is "class code."

I want a text box to be populated with the "title" which corresponds
to the
"class code" which I enter in the form. The control source for the
text box
is:

=DLookUp("[Title]","[class code descriptions]","[CCode] =

forms![CCode]")
[this is literally what I have in the control source for the field.]

I get no value returned when I know that there is are corresponding

values
in the table.

What am I missing here?

thanks in advance,
jlm

Re: > Key field is "class code."
Is the Key Field "Class Code" or is it "CCode"?
If the field is actually named "CCode" and it is a Number Datatype,
then:

=DLookUp("[Title]","[class code descriptions]","[CCode] = " &
Me![CCode])

where [CCode] is the name of the control on the form that shows the
number to look up.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.


Key field is actually CCode and is text.

Then use:
=DLookUp("[Title]","[class code descriptions]","[CCode] = '" &
Me![CCode]) & "'")

With spaces addedd for clarity, the Where clause is:
"[CCode] = ' " & Me![CCode]) & " ' ")
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.


There must be something really wacked out because it won't work no matter
what I enter. This can't be that difficult. BTW, can you explain the "&"
symbols and the role they play?
thx
Nov 12 '05 #5

P: n/a
On Wed, 18 Feb 2004 15:15:44 -0700, JLM wrote:

** snipped **
Key field is actually CCode and is text.

Then use:
=DLookUp("[Title]","[class code descriptions]","[CCode] = '" &
Me![CCode]) & "'")

With spaces addedd for clarity, the Where clause is:
"[CCode] = ' " & Me![CCode]) & " ' ")
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.


There must be something really wacked out because it won't work no matter
what I enter. This can't be that difficult. BTW, can you explain the "&"
symbols and the role they play?
thx


1) Let me verbalize the above lookup and see if my using words can
explain what the code does. This way, if you see an error in my logic,
you can change a Field or table name.

= Get the data in the Field named [Title] located in the Table named
[class code descriptions] where the Field in that table named [CCode]
matches the control on this form named also named [CCode].
Note: [CCode] (as per your previous post) is Text datatype.

If it still doesn't work ....
Please state what you get (or don't get).
Is there an error given?
Please copy and paste the entire DLookUp you are using.
Please also give the EXACT table and field names in the table, as well
as the name of the control on the form that contains this DLookUp.

2) The & is used to concatenate strings (put them together), so that
if you write = "This is " & "a line of " & "Text", it would read
"This is a line of text".

In the where clause portion of the DLookUp above, Access will assemble
the clause like this, (assuming the value in the [CCode] control in
the form is "ABC123"):
"[CCode] ='ABC123' "
(I've separated the single and double quotes for clarity.)
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 12 '05 #6

P: n/a
JLM

"fredg" <fg******@att.net> wrote in message
news:au***************************@40tude.net...
On Wed, 18 Feb 2004 15:15:44 -0700, JLM wrote:

** snipped **
Key field is actually CCode and is text.
Then use:
=DLookUp("[Title]","[class code descriptions]","[CCode] = '" &
Me![CCode]) & "'")

With spaces addedd for clarity, the Where clause is:
"[CCode] = ' " & Me![CCode]) & " ' ")
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.


There must be something really wacked out because it won't work no matter what I enter. This can't be that difficult. BTW, can you explain the "&" symbols and the role they play?
thx


1) Let me verbalize the above lookup and see if my using words can
explain what the code does. This way, if you see an error in my logic,
you can change a Field or table name.

= Get the data in the Field named [Title] located in the Table named
[class code descriptions] where the Field in that table named [CCode]
matches the control on this form named also named [CCode].
Note: [CCode] (as per your previous post) is Text datatype.

If it still doesn't work ....
Please state what you get (or don't get).
Is there an error given?
Please copy and paste the entire DLookUp you are using.
Please also give the EXACT table and field names in the table, as well
as the name of the control on the form that contains this DLookUp.

2) The & is used to concatenate strings (put them together), so that
if you write = "This is " & "a line of " & "Text", it would read
"This is a line of text".

In the where clause portion of the DLookUp above, Access will assemble
the clause like this, (assuming the value in the [CCode] control in
the form is "ABC123"):
"[CCode] ='ABC123' "
(I've separated the single and double quotes for clarity.)
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.


From reading the online help sections of DLookup, I understand the logic of
the function. But for some reason, it isn't returning any data. Here are
the details of my situation.

Form: (I've modified it slightly since my last post. The changes are shown
here.) I created a Text Box called LookupTitle, on a form. In the Control
Source of this box I have, =DLookUp("[Title]","[class code
descriptions]","[CC] = ' " & Me!CC & " ' "). (Btw, I think your example had
an extra ")" in it.) With this in place, and when I look at the FormView,
the text box reads, #name?. When I enter a value in the CC field (which
will populate [TblEmp].[CC]), I expect to see LookupTitle filled with data.
(I didn't realize that "&" can be used in this instance. I use it all the
time in queries (which I guess is what I'm trying to do with DLookup).)

The form data source is a query that includes, among other things, the Class
Code and Title of each employee listed in that table. Fields CC and Title
on both tables have identical properties.

Table name: class code descriptions
fields: CC - text 6, Title - text 30.
record example: B2F2XX Budget Analyst II

Thanks for your patience in this. Let me know if I've omitted anything in
my description.
jlm
Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.