Problem with DLookup

aecarpin

New member
Local time
Today, 23:46
Joined
Mar 2, 2005
Messages
6
I can find out what is wrong with my code. :confused:

"TransfereeName" is a textbox where the string is either typed in or obtained from a combo. I want the "TransfereeAddress" to automatically filled in when the name is selected from the combo. The combo does contain the Address as well, but I don't know how to capture it to fill in the "TransfereeAddress" automatically.

I get the following error: Run-Time error '2001' - You canceled the previous operation.

I thought by using DLookup I can obtained the address of the Transferee.

Dim NAddress As String

This is not working
NAddress = Nz(DLookup("[Address]", "tblShareMembers", "[Member] = '" & Me.TransfereeName & "'"), "")

This one doesn't work either.
NAddress = DLookup("[Address]", "tblShareMembers", "[Member] = '" & TransfereeName & "'")

I'd appreciate your help please!!!
 
Thanks, but I still can't see where the problem is. The examples given on MS site shows the criteria (string) is hardcoded rather than supplied from a textbox object which confuse me.
 
aecarpin said:
I can find out what is wrong with my code. :confused:

"TransfereeName" is a textbox where the string is either typed in or obtained from a combo. I want the "TransfereeAddress" to automatically filled in when the name is selected from the combo. The combo does contain the Address as well, but I don't know how to capture it to fill in the "TransfereeAddress" automatically.

I get the following error: Run-Time error '2001' - You canceled the previous operation.

I thought by using DLookup I can obtained the address of the Transferee.

Dim NAddress As String

This is not working
NAddress = Nz(DLookup("[Address]", "tblShareMembers", "[Member] = '" & Me.TransfereeName & "'"), "")

This one doesn't work either.
NAddress = DLookup("[Address]", "tblShareMembers", "[Member] = '" & TransfereeName & "'")

I'd appreciate your help please!!!

What about:

NAddress = DLookup("Address", "tblShareMembers", "Member = '" & TransfereeName & "'")

Before I assume syntax error, have you had any problems with Dlookups before?

Also, is it a bound or non bound forrm?
 
Hi, I am not to clear on the bound and unbound form, but the combo and the textbox field "TranfereeName" & "TranfereeAddress" are on a subform which is the Source Object of a form called frmCompaniesDetail (hope this make sense - see attachment).

I've tried the code you've given but it still doesn't work.
This is the first time I use DLookup.
 

Attachments

  • tranferee.JPG
    tranferee.JPG
    38.2 KB · Views: 150
Last edited:

Users who are viewing this thread

Back
Top Bottom