DLookUp

AdamH

New member
Local time
Today, 18:59
Joined
Apr 18, 2002
Messages
5
I created the following behind a field in a form DLookUp("[CMSRPhoneNumber]","[tbl:CM Sales Rep]","[CMSRName]='" & [frm:Main Table].[Combo134] & "'"). I have a table that contains two fields, Name and Phone Number. On a form, I have a combo box with a persons name listed from this table. I want to automatically populate the phone number into another field on this form. I can get the Dlookup to work in a Query but it will not work on the form. I put the expression in the BeforeUpdate section of the field. HELP!
 
Create your combo so the name and phone number are in it. Assume name is the first column and phone the second. In the After Update event of the combo box use code like this:

Me.PhoneFieldOnForm = Me.ComboBoxName.Column(1)
 
Get rid of your Dlookup, it's inefficient and not needed here as long as there is a 1:1 ratio between name and phone number.

Add another column to your combo. Make the width 0" so you can't see it in the dropdown, but the data will be there. Then in your Phone Number box, make the record source =Combo134.Column(2)

(I think the column number is right, you might have to fiddle that part)

Lock the field so people don't try to modify it, and you're good to go. No code required.

P.S. Hi Jack!

[This message has been edited by David R (edited 04-24-2002).]
 
Worked beautifully!! YOU GUYS RULE - Thank you so much!!!!!
 

Users who are viewing this thread

Back
Top Bottom