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

Combo boxes 11

Status
Not open for further replies.

LowNissan

Technical User
Jan 29, 2001
4
0
0
US
I'm setting up a form to insert info into my table about vehicle info. Is there a way that I can have 2 combo boxes, one with makes (ie Ford, Chevy..) and one with models (ie C/K, Tahoe, Ranger...), so when I select the make, it'll make the models field only load vehicles for that model. So if I click on Chevy, it'll only load chevy cars.
 
Thanks for the tip, Gus.

BTW, a related article in the Microsoft Knowledge Base is worth a look, too. It provides step-by-step instructions as you create synchronized combo boxes in the Northwind database. I was able to successfully create linked combo boxes following their instructions.

The article is titled "How to Synchronize Two Combo Boxes on a Form" and is Article ID #Q7624. It can be found by searching for the article ID at this link:
Good luck!
 
RickSpr wrote a decent FAQ on this subject for this forum. Go the main page for this forum and click on FAQs then scroll down to User Interface Techniques.

Or follow this link:
Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
 
what about the following corollary of this'....

let's say that there are is a combo box and a text box. once you look up the value of the combo box and select it from the available values, you want the corresponding value of that value's to be stored in the text box. naming names, my combobox would be called 'protocol id' and the text box would be called 'title'. there will always be a 1:1 correspondence between 'protocol id' and 'title' and they will have been pre-entered into a table called 'study_info'.

is that doable?
 
Okay, first, you can set your combo RowSource Property to refer to the Table in string data type, and have the RowSource Property set to "Table/Query"

Now, assuming the following:

ProtocolID is the first column
Title is the second column

Use the Combobox's AfterUpdate Event to update the value in the textbox as follows:

Private Sub cbxProtocol_AfterUpdate()
Me.tbxTitle.Value = Me.cbxProtocol.Column(1)
End Sub

Normally for something like this, I may use a label unless it's being used to lookup the protocol ID number.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
 
yup, seems to work like a charm :) only one question, though: i was using a SQL instruction in lieu of the name of the 'Protocol' table as the source of the data for 'Protocol ID' and until i 'experimented' with sub'ing the table name for it, it wouldn't work?
 
You can use SQL Statement in the RowSource Property of the combo-box, as I have done that before. Just remember, the SQL Statement MUST BE IN STRING DATA TYPE, else this won't work.

Me personally, I don't normally bound controls/forms, but there may be such cases to do that. My biggest reason is cause thre is no such thing in Access that acts like the CausesValidation Property and Validate Event which is in VB6, so I had to create my own similation of these 2 things, which meant my forms and controls had to be UNBOUND for this to work.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
 
i wish i knew what you were intending to say when you say 'Just remember, the SQL Statement MUST BE IN STRING DATA TYPE, else this won't work' - what is STRING DATA TYPE?
i do not believe i have a working acquaintance with that terminology. otherwise, all's well that ends well, i guess.
 
There are various data types that VBA uses. String Data Type is just that, the veriable is evaluated as a string, which contains the literal characters.

Example:

"12"

is in string format while

12

is a numeric value, which could be in a number of data types (Byte - only 1 byte, which the range is 0 to 255, Integer, which the range is from 0 to 32767, and so on) For additional information on the various data types, goto the Access help file from a form in design view, goto Content, then drill down the list of topics:

Microsoft Access Help
Programming in Visual Basic
Visual Basic Language Reference
Data Types

This then contains the list of data types that's in VBA.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top