DLookup

G

Guest

Hi,

I have a report that has the following two fields that lookup a value in the
"Host" table:

Text16 =DLookUp("[FirstName]","Host","[Title] = 'General Chairman'")
Text17 =DLookUp("[LastName]","Host","[Title] = 'General Chairman'")

Then I mrege the two fields into one field "Full Name", and dispaly it:

Full Name = [Text16] & " " & [Text17]

I made the "Text16" and "Text17" invisible, and I have no problem previewing
the report. I was just wondering whether there was a "cleaner" way to do
that?!!

Thanks
 
G

Guest

I am guessing that Full Name is a text box on the report. What you are doing
is okay. There are always more than one way to do something and you will see
a lot of people claim their way is by far the best. In reality, unless you
can see there is a problem created by an approach, or performance gets really
bad, then however you get it done is good. This is not an absolute, there
are some things that are bad ideas for a variety of reasons, but I am getting
too Philosophical, You could:

Full Name =DLookUp("[FirstName]","Host","[Title] = 'General Chairman'") &
DLookUp("[LastName]","Host","[Title] = 'General Chairman'")
 
D

Duane Hookom

You only need one DLookup():
=DLookUp("[FirstName] & ' ' & [LastName]","Host","[Title] = 'General
Chairman'")
 
G

Guest

duh, yep you are correct. Now that I have activated my brain, the question
is can there be more than one row with the [Title] = 'General Chairman'?

Duane Hookom said:
You only need one DLookup():
=DLookUp("[FirstName] & ' ' & [LastName]","Host","[Title] = 'General
Chairman'")


--
Duane Hookom
MS Access MVP
--

Muneer Mikel said:
Hi,

I have a report that has the following two fields that lookup a value in
the
"Host" table:

Text16 =DLookUp("[FirstName]","Host","[Title] = 'General Chairman'")
Text17 =DLookUp("[LastName]","Host","[Title] = 'General Chairman'")

Then I mrege the two fields into one field "Full Name", and dispaly it:

Full Name = [Text16] & " " & [Text17]

I made the "Text16" and "Text17" invisible, and I have no problem
previewing
the report. I was just wondering whether there was a "cleaner" way to do
that?!!

Thanks
 
D

Duane Hookom

DLookup() would still work if there were more than one but I wouldn't rely
on returning the correct one from the function.

--
Duane Hookom
MS Access MVP


Klatuu said:
duh, yep you are correct. Now that I have activated my brain, the
question
is can there be more than one row with the [Title] = 'General Chairman'?

Duane Hookom said:
You only need one DLookup():
=DLookUp("[FirstName] & ' ' & [LastName]","Host","[Title] = 'General
Chairman'")


--
Duane Hookom
MS Access MVP
--

Muneer Mikel said:
Hi,

I have a report that has the following two fields that lookup a value
in
the
"Host" table:

Text16 =DLookUp("[FirstName]","Host","[Title] = 'General Chairman'")
Text17 =DLookUp("[LastName]","Host","[Title] = 'General Chairman'")

Then I mrege the two fields into one field "Full Name", and dispaly it:

Full Name = [Text16] & " " & [Text17]

I made the "Text16" and "Text17" invisible, and I have no problem
previewing
the report. I was just wondering whether there was a "cleaner" way to
do
that?!!

Thanks
 
G

Guest

Duane, Klatuu, thank you so much :)
Now it is much better than the way I had it before. Also, there is only one
row with the [Title] = 'General Chairman', or any other title.

Thanks

Duane Hookom said:
DLookup() would still work if there were more than one but I wouldn't rely
on returning the correct one from the function.

--
Duane Hookom
MS Access MVP


Klatuu said:
duh, yep you are correct. Now that I have activated my brain, the
question
is can there be more than one row with the [Title] = 'General Chairman'?

Duane Hookom said:
You only need one DLookup():
=DLookUp("[FirstName] & ' ' & [LastName]","Host","[Title] = 'General
Chairman'")


--
Duane Hookom
MS Access MVP
--

Hi,

I have a report that has the following two fields that lookup a value
in
the
"Host" table:

Text16 =DLookUp("[FirstName]","Host","[Title] = 'General Chairman'")
Text17 =DLookUp("[LastName]","Host","[Title] = 'General Chairman'")

Then I mrege the two fields into one field "Full Name", and dispaly it:

Full Name = [Text16] & " " & [Text17]

I made the "Text16" and "Text17" invisible, and I have no problem
previewing
the report. I was just wondering whether there was a "cleaner" way to
do
that?!!

Thanks
 

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