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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Text Box

Status
Not open for further replies.

MAPetry

Technical User
Aug 2, 2000
43
US
I have a subform that lists various selected companies, contacts, and phone numbers. I want to automatically populate the phone box (Text)with the phone number of the company. I am doing the exact same thing with the contact and have no problems because it is a combo box and I have written code to select the Row source. However since the text box does not have a rowsource i am having problems getting it to automatically display the phone number. What little property am I looking over that needs to be set for this to work?

Any help would be appreciated.
 
I'll give you one really simple way to do this among many,
You built the query for the customer combo? Add to that query the phone number and note its column position (1st column is 0) so perhaps your phone column is 4

Add 1 more column count to the combo, and add a width appropriate for the phone no. if you want to show it, or 0 if you don't. Adjust the list width to suite if you did the former.

Now, in the after update event for the combo (Combo properties-Events tab-After update-Choose "event procedure-click "..." beside to open Visual Basic and automatically label a sub for this event) add something like this:

Me![NameOfYourPhoneTextBox]=Me![NameOfYourCombo].Column(4)

One of many options you can use and you can take this even further with fax/email/...you name it! Gord
ghubbell@total.net
 
Yes, I think that I will have to set up a query and base my form on the query. I was hoping that I could eliminate that step by building an expression or code to default the box value but I guess you can't.

Thanks for the help.

MAP
 
While a query is one way to go, you can create a list or combo box, with the phone number, address, etc in additional columns. You can display data from a listbox column with the following expression: =[<listboxname>].[column](#), where # is the column number, starting with 0. For example, =[listbox].[column](0) will display the data from the firsr column of the list.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top