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

How to have combo box selection update other fields 2

Status
Not open for further replies.

number2

Technical User
Oct 25, 2001
284
US
I am trying to do the following:
1)After selecting a contact name from a combo box
2) Have the following address fields update to the contacts address information.

Thanks
 
For the Row Source property of the combo box create a query, that has all the fields that you want to be displayed in text boxes. If you don't want them displayed in the combo box, set Column widths property appropriatelly.

Say you have two text boxes on the form that need to be updated: txtStreet and txtCity. In the query the Contact is the first field, Street is the second field and City is the third.

In the AfterUpdate event of the combo box write something like this:

txtStreet = Combobox.Column(1)
txtCity = Combobox.Column(2)

Columns start counting from 0 so the second column has index 1, the third 2...
 
Thanks for the easy to understand solution. I entered what appears to be correct code, but with text fields do not update. here is my code:
Attorneyadd = Attorney.Column(2)
attcitystzip = Attorney.Column(3)

any ideas?
 
Hmmmm...check the query in the row source property of the combo box. Is the third field address and the fourth zip? Make sure, that you have the Show property in QBE grid (query design) checked for the fields you need. Test the query by displaying it in a DataSheet view (choose DataSheet view from View menu in query design). Are all the needed columns displayed?
 
I beleive I found the problem; it was a naming clitch. Feild names verse feild source. At any rate it seems to work! Very nice, thanks so much. It works only if the feild data is entered; ie if one of the address feilds is empty a runtime error 3315 comes up. Any solution to that? I think others will benifit from your solution!
 
It seems that you have the Allow Zero Length property set to False for the fields being updated, so some value must be entered. Change the property in the table design. Also, check out the Required property.
 
Dear number2:
You got some very good advice from MangroBongacello. Why didn't you click to "Let MangroBongacello know this post was helpful!"? Never mind, I'll do it for you...he deserves a star.
Gus Gus Brunston
An old PICKer
padregus@home.com
 
MangroBongacello, thanks so much! I am unable to find the Allow Zero Length property you mentioned. Sorry to be a bother, but where might I find this? I am using A'97.
 
Open the design view of the table. Select one field (for example Attorneyadd). At the bottom of the window are some properties you can set for the field. If the field is of Text type, which I assume it is, there is also Allow Zero Length property displayed. Change it to Yes if not all the fields will contain some text. For more info see the AllowZeroLength property topic in the Access Help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top