Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autofill Text Box Based on Combo Box Entry

Status
Not open for further replies.

dshannon

Technical User
May 25, 2002
11
US
I have read more than a few threads on this issue, but still have some questions. Maybe someone can help?

I have a combo box (architectural_firm) for a Contact. I would like to have the telephone and fax numbers that are with this record in the table, automatically fill in the form when the Contact is chosen.

I tried Braindead2's suggestion of May 2, 2001 and set the combo box's rowsource to select the telephone and fax numbers from my table. I then set the combo box column count to 3 and set the column widths to hid the last two columns (1.5";0";0"). I attempted to set the textbox (arch_telephone)control source to =[arch_telephone].column(1)&" "&combo1.column(2). But when I do this, I still get #Name? in my text box when I test out the form.

Would someone enlighten me as to what silly mistake I am making?

Thank you in advance!
Dianne in Virginia :)
 
It's not pretty but a workaround I used for this a while ago was this:
1) Create a subform on your form and base it on your arch_firm table.
2) Make sure this form has text boxes for the phone and fx numbers on it.
3) Create your combo to lookup firms on this subform, using the wizard and choosing the option 'Find a record on my form based on the value I select in the combo box....' result, when you select an entry in the combo the phone and fax numbers appear.
4) Make all the controls on the subform invisible and shrink it down so it looks like just the combo box- the user will never know it is there.
5) Add code to the combo box After-Update event along the lines of: Forms![nameofmainform]![arch_telephone]=Me![arch_telephone], ditto for the fax no.

This should give what you want. However, as I say it is a workaround and certainly not ideal, I am more than happy for someone to describe a better way!

Nigel
 
Sorry correction- point 4 should say make all controls on the subform EXCEPT THE COMBO invisible....
I'm sure you would have worked that out!!
 
Let's try this one more time.

Assuming the name of your combo box is architectural_firm and the name of your text box for the telephone number is arch_telephone.

Also assuming the combo box row source is 3 columns
Contact, telephone, fax.

Contact is column 0
Telephone is column 1
Fax is column 2

Your text box arch_telephone control source is
=architectural_firm.column(1)

Your text box arch_fax control source is
=architectural_firm.column(2)

You are saying "Look in my combo box and find the value in this column and put it here"

HTH


 
SKO:

THANK YOU!!!!!


I will try this today.

Dianne in Virginia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top