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!

Populate a field in a form based on combo

Status
Not open for further replies.

farnorth

Technical User
Aug 14, 2002
32
US
I have a combo box with a choice of names. I want to have 2 fields populate with data that is part of the option chosen in the conbo box. for example.

Choose
Name: Car# Class
Joe Smith 33 Open

When you choose Joe Smith in the Combo box it populates the next tow fields with items from the db associated with Joe Smith.... His Car # and Class.

I have been reading help and messing with this all day... but... it has eluded me.

Thanks in advance for the help!
 
Hi

You have two choices here.

Does the record source of the combo box include the additional information (ie Car and Class)?

If yes you could make a three column combo box (eg col1 = Name, col2=car,col3=class), you hide cols 2 & 3 by setting thier width property to zero. Then you can populate your text boxes with syntac like so:

txtCar = cboName.Column(2)
txtClass = cboName.Column(3)

in the after update event of the combo box

If the record source does not / cannot include the car and class, then you need to execute some SQL to look up the data in what every table. If this is the situation, post back including which table the information is in, and its key.

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hey Ken, I tried your suggestion for the combo box after update and VB came up stating it could not find object. Your suggestion will work for me... Am I missing anything? FYI I am using access 2000.

Thanks,

Bob
 
Hi

You have adjsuted the code examle to use your own control names haven't you?

If yes, on which line does it stop? Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I have, my combo box name is "Name". It appears to stop on txtCar =.
 
Hi

So you have a textbox control called txtCar and a line of code like:

txtCar = Name.Column(2)

Is that what you are saying?

Name is not a good name if you will pardon the pun, becuase it is an access reservered word, all objects have a propert called name, so it is easy to cause confusion eg

name.name

you should use a naming convention to help avoid such foul ups Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top