DLookup

sandrao

Registered User.
Local time
Today, 15:38
Joined
Sep 6, 2007
Messages
34
I have a form in which I am scheduling speakers it called “Speaker Assignments”

I am trying to use DLookup to retrieve information from a Table called
“SpeakerInfo” I have created a unbound text box called “txtSelectSpeaker”.
What I want to do is enter the last name of the speaker in the unbound text
box and using after update when I tab out I want the information to be placed
in other field..

In the “SpeakerInfo” Table I have the following fields: “SpeakerName” (just
Last Name) “CityName” , “PhoneNumber” and finally “FullName”. What I want
to accomplish is to be able to type in the last name of speaker and tabbing
out place the “FullName” in the field “Speaker” the “CityName” in the field
“City” and finally the “PhoneNumber” in a the field “ContactNumber” the first
line of code that was to place the FullName into the “Speaker” field is:
Me.Speaker = Nz(DLookup("[SpeakerName]", "[SpeakerInfo]", "[FullName]= " &
Me.txtSelectSpeaker), "")

This of course didn’t work. Can anyone help.
 
with a text field the where bit needs to be enclosed in inverted commas

so it looks like

[fullname] = "whatevername"

to do this you need to code the inverted commas, and the easiest way is to use chr(34). If you try to use " directly you get caught by having to use double quotes to get a single quote which is awkward. Using chr(34) bypasses this

so you want something like
"[FullName]= " & chr(34) & Me.txtSelectSpeaker & chr(34)), "")


note if you use a date you have to use the # character to surround the date.
 

Users who are viewing this thread

Back
Top Bottom