Combo boxes are so-named because they "combine" the features found in both text boxes and list boxes. Combo boxes are also commonly referred to as "drop-down boxes" or "drop-down lists". There are three combo box styles:
At design-time, you set the style of the combo box with its Style property.
Of the three combo box styles, the one most similar to a ListBox is "2 - Drop-Down List". In fact, everything discussed in the last several pages regarding ListBoxes applies to drop-down style combo boxes EXCEPT the following:
The combo box displays the selected item in the text box portion of the combo box. The ListBox portion of the combo box remains hidden until the combo box receives focus and the user clicks the down arrow on the text box.
You can change the width of a drop-down combo box, but not its height.
Like a ListBox, and unlike the other combo box styles, the user can only select a value that is in the list they cannot type in a new value. However, if the user does press a keyboard key, the closest item in the list alphabetically will be selected (i.e., if the user types the letter "B", and the word "Banana" is in the list, then "Banana" will be selected).
Multiple selections cannot be made. Only one item may be selected from the list.
Unlike a ListBox, VB does not automatically pre-select the first value from a combo box. Therefore, the initial value of the ListIndex property is 1. If you do not pre-select a value in code (say in the Form_Load procedure), then be sure to check the ListIndex property for a value of 1 when you check to see which item the user selected.
The "0 Drop Down Combo" style of combo box operates the same way as the Drop Down List, except that the user may type a new value in the text box portion of the combo box. Please note that if the user types a non-list value, this value is NOT automatically added to the list, and the value of ListIndex would be 1. You should check the Text property to access the user's selection or entry.
The "1 Simple Combo" style of combo box operates in a manner similar to the Drop Down Combo in that the user can either select an item from the list or type a new entry. The difference is that the list does not drop down like a ListBox, you determine the height of the list portion at design-time. This is the only combo-box style that allows you to adjust the height of the list portion.
Combo Box Demo Program
A sample program to demonstrate the three combo box styles will now be presented. The form at design-time is shown below:

Frame1 has the Caption 'Style "2 Dropdown List"' and contains a combo box named cboFood with its Style property set to 2 Dropdown List. It also contains three command buttons, named cmdLoadFoodCombo, cmdSelect, and cmdDetermine. It also contains a checkbox named chkAuto.
Frame2 has the Caption 'Style "0 Dropdown Combo"' and contains a combo box named cboStateAbbrev with its Style property set to 0 Dropdown Combo. It also contains two command buttons, named cmdLoadStateAbbrevCombo and cmdAddNewAbbrev.
Frame3 has the Caption 'Style "1 Simple Combo"' and contains a combo box named cboStateName with its Style property set to 1 Simple Combo. It also contains two command buttons, named cmdLoadStateNameCombo and cmdAddNewName.
We will first look at the code dealing with the Dropdown List style of the combo box.
The cmdLoadFoodCombo_Click Event
In this event, we first clear the cboFood combo box, then manually add three food items along with their calorie count in the corresponding ItemData property. (See the earlier discussion "Getting Data into a Listbox" for more detail.) We then inform the user that the combo box has been loaded.
Private Sub cmdLoadFoodCombo_Click()
cboFood.Clear
cboFood.AddItem "Orange"
cboFood.ItemData(cboFood.NewIndex) = 60
cboFood.AddItem "Apple"
cboFood.ItemData(cboFood.NewIndex) = 80
cboFood.AddItem "Banana"
cboFood.ItemData(cboFood.NewIndex) = 105
MsgBox "Food combo box has been loaded.", _
vbInformation, _
"Combo Box Demo"
End Sub
Note: When you run the sample application and click this button, you will not initially see these items, because we are not pre-selecting any item:

You have to click the down arrow on the combo box to see the items:

If you wanted to pre-select an item in the combo box, you would set the ListIndex property to the index of the desired entry. For example, the statement cboFood.ListIndex = 0 would pre-select the first item in the box.
The cmdSelect_Click Event
The purpose of the code behind the cmdSelect button is to show how to select a specific entry from a combo box in code. Given an item to match against, you loop through the entries in the combo box until you either find a matching entry or you go through the entire list without finding the entry. If you find the desired entry, you set the ListIndex property to that of the matching entry and exit the loop early. In this example, an InputBox prompts the user to enter a food. We then loop through the entries of the combo box, comparing the current List entry to the food item entered in the InputBox. If and when the item is found, the ListIndex is set accordingly.
Private Sub cmdSelect_Click()
Dim strFood As String
Dim intX As Integer
Dim blnFound As Boolean
strFood = InputBox("Please enter the food to select (apple, orange, or banana).", _
"Combo Box Demo - Select with Code")
If strFood = "" Then Exit Sub
blnFound = False
For intX = 0 To cboFood.ListCount - 1
If UCase$(cboFood.List(intX)) = UCase$(strFood) Then
cboFood.ListIndex = intX
blnFound = True
Exit For
End If
Next
If Not blnFound Then
MsgBox "Item was not found in the list.", _
vbExclamation, _
"Combo Box Demo"
End If
End Sub
Below are screen shots of a sample run:
|
User types "apple" in the InputBox:
|
The item is found in the combo box and selected:
|
Note: This exact same technique can be used to match on an ItemData entry in the list. For example, the code could be modified to accept a number, then you could loop through the combo box entries looking for an ItemData entry that matched that number. The check could be done with a statement similar to If cboFood.ItemData(intX)) = MyNumericEntry Then ...
The cmdDetermine_Click Event
The purpose of the code behind the cmdDetermine button is to show how you determine and obtain the value of the item that has been selected in the combo box. Again, our friend the ListIndex property is used. The value of the text portion of the selected item is given by ComboBoxName.List(ComboBoxName.ListIndex). If there is a corresponding ItemData item, that value is given by ComboBoxName.ItemData(ComboBoxName.ListIndex).
Private Sub cmdDetermine_Click()
If cboFood.ListIndex = -1 Then
MsgBox "There is no item currently selected.", _
vbInformation, _
"Combo Box Demo"
Exit Sub
End If
MsgBox "You have selected " & cboFood.List(cboFood.ListIndex) & "." & vbNewLine _
& "It has " & cboFood.ItemData(cboFood.ListIndex) & " calories.", _
vbInformation, _
"Combo Box Demo"
End Sub

The cboFood_Click Event
The purpose of the code behind the cboFood_Click event is to show that the value of the selected items can be obtained as soon as the user selects it from the drop-down list. This behavior can be examined by first checking the chkAuto checkbox, then by selecting an item from the cboFood combo box.
Private Sub cboFood_Click()
If chkAuto.Value = vbChecked Then
Call cmdDetermine_Click
End If
End Sub
Next, we will look at the code dealing with the Dropdown Combo style of the combo box.
The cmdLoadStateAbbrevCombo_Click Event
This event loads the cboStateAbbrev combo box with U.S. state abbreviations from a comma-delimited sequential file called STATES.DAT. The records in the file contain two fields, the state abbreviation and state name; only the abbreviations are loaded into the combo box. No values are added to the optional ItemData property array of the combo box. As was the case with loading the food combo box, no item is pre-selected after loading the state abbreviations, so you will not see the entries until you click the arrow on the drop-down box.
Private Sub cmdLoadStateAbbrevCombo_Click()
Dim intStateFileNbr As Integer
Dim strBS As String
Dim strStateAbbrev As String
Dim strStateName As String
strBS = IIf(Right$(App.Path, 1) = "\", "", "\")
intStateFileNbr = FreeFile
Open (App.Path & strBS & "STATES.DAT") For Input As #intStateFileNbr
cboStateAbbrev.Clear
Do Until EOF(intStateFileNbr)
Input #intStateFileNbr, strStateAbbrev, strStateName
cboStateAbbrev.AddItem strStateAbbrev
Loop
Close #intStateFileNbr
MsgBox "State abbreviation combo box has been loaded.", _
vbInformation, _
"Combo Box Demo"
End Sub
The cmdAddNewAbbrev_Click Event
This event shows that with this type of combo box, you can type in a new entry in the textbox portion of the combo box. However, a new entry is not automatically added to the list portion of the combo box. If you wish to do this, you must do so with code, as the code in this event procedure demonstrates. When the "Add New Item to List" button is clicked, this code runs to first check that the item is not already in the list, and if not, adds it.
Private Sub cmdAddNewAbbrev_Click()
Dim intX As Integer
If cboStateAbbrev.Text = "" Then Exit Sub
For intX = 0 To cboStateAbbrev.ListCount - 1
If UCase$(cboStateAbbrev.Text) = UCase$(cboStateAbbrev.List(intX)) Then
MsgBox "Item '" & cboStateAbbrev.Text & "' is already in list.", _
vbExclamation, _
"Combo Box Demo"
Exit Sub
End If
Next
' if we get here, the item entered in text portion is not in the list
cboStateAbbrev.AddItem cboStateAbbrev.Text
MsgBox "Item '" & cboStateAbbrev.Text & "' has been added to the list.", _
vbExclamation, _
"Combo Box Demo"
End Sub

Finally, we will look at the code dealing with the Simple Combo style of the combo box.
The cmdLoadStateNameCombo_Click Event
This event loads the cboStateName combo box with U.S. state names from the same comma-delimited sequential file called STATES.DAT. The records in the file contain two fields, the state abbreviation and state name; only the names are loaded into the combo box. No values are added to the optional ItemData property array of the combo box. As was the case with loading the food and state abbreviation combo boxes, no item is pre-selected after loading the data. However, since the list portion of this style of combo box is visible, you will see the entries after they have been loaded.
Private Sub cmdLoadStateNameCombo_Click()
Dim intStateFileNbr As Integer
Dim strBS As String
Dim strStateAbbrev As String
Dim strStateName As String
strBS = IIf(Right$(App.Path, 1) = "\", "", "\")
intStateFileNbr = FreeFile
Open (App.Path & strBS & "STATES.DAT") For Input As #intStateFileNbr
cboStateName.Clear
Do Until EOF(intStateFileNbr)
Input #intStateFileNbr, strStateAbbrev, strStateName
cboStateName.AddItem strStateName
Loop
Close #intStateFileNbr
MsgBox "State name combo box has been loaded.", _
vbInformation, _
"Combo Box Demo"
End Sub

The cmdAddNewName_Click Event
As was the case with state abbreviation combo box, this event shows that with this type of combo box, you can type in a new entry in the textbox portion of the combo box. However, a new entry is not automatically added to the list portion of the combo box. If you wish to do this, you must do so with code, as the code in this event procedure demonstrates. When the "Add New Item to List" button is clicked, this code runs to first check that the item is not already in the list, and if not, adds it.
Private Sub cmdAddNewName_Click()
Dim intX As Integer
If cboStateName.Text = "" Then Exit Sub
For intX = 0 To cboStateName.ListCount - 1
If UCase$(cboStateName.Text) = UCase$(cboStateName.List(intX)) Then
MsgBox "Item '" & cboStateName.Text & "' is already in list.", _
vbExclamation, _
"Combo Box Demo"
Exit Sub
End If
Next
' if we get here, the item entered in text portion is not in the list
cboStateName.AddItem cboStateName.Text
MsgBox "Item '" & cboStateName.Text & "' has been added to the list.", _
vbExclamation, _
"Combo Box Demo"
End Sub

Download the project files for the combo box demo program here.
*** BONUS MATERIAL ***
ComboBox Procedures
Presented below are several examples of how to extend the functionality of the combobox.
Extend the Number of Items Displayed
By default, when you click the drop-down arrow of a combo box, VB will display a maximum of eight items. This example shows how you can set up the combo box to display as many items as you want when the drop-down arrow is clicked.

Download the project files for this example here.
Extend the Width of the Drop-Down List
By default, the drop-down list of a combo box is the same width as the combo box itself. This example shows how you can set up the combo box so that the width of the drop-down list is as wide as the widest item in the list.

Download the project files for this example here.
Automatically Drop Down the List when ComboBox Receives Focus
This example shows how you can automatically display the drop-down list (as opposed to having the user click the drop-down arrow) when the combo box receives focus.

Download the project files for this example here.
Creating a "Multi-Select" Checkbox-ComboBox
This example shows how you can simulate a combo box where the items in the drop-down list have checkboxes, enabling you to make multiple selections. The multiple selections are shown comma-delimited in the text portion of the combo box. This example does not actually use a combo box the text portion is actually a picture box containing a label and a graphical-style command button for the drop-down arrow. When the command button is clicked, a checkbox-style listbox is displayed.

In this sample program, when you click the "Show Selected Items" button, a message box is displayed, showing both the items that were selected, as well as the corresponding ItemData items, both "as is" as well as enclosed in quotes.

Download the project files for this example here.
Search-As-You-Type ComboBox
This example shows how you implement "search-as-you-type" functionality with a combo box. As you type characters in the textbox portion of the combo box, the first item in the list that starts with those characters will be selected. In the screen shot below, as soon as the user types "o" in the box, "onion rings" is selected. This example limits the user to items contained in the list.

Download the project files for this example here.
Search-As-You-Type ComboBox (Enhanced Database Example)
This example extends the "search-as-you-type" functionality demonstrated in the previous example by using database lookups, and this implementation does NOT limit the user to the items contained in the list. If the user types in an item that is not already in the list and clicks the Refresh button, the new item will show up the next time the list is dropped down (i.e., the new item will be inserted into the database table).

A couple of options can be used to modify the behavior of the combo box. You can choose to have the program load items based on the first letter typed (i.e., as shown in the screen shot above, when you type the letter "B", load only the companies that start with the letter "B"). This option makes sense when you are selecting values from a large database table. Alternatively, you can choose to have the program load all values from the database table at once. That option would be suitable for smaller tables.
Also, you can choose whether or not you want the drop-down box to be displayed as soon as focus is moved to the combo box.

Download the project files for this example here.
Comments
e-mail
can u answer this?
the command should Remove all items from the ComboBox by clearing it and adding it all to a listbox.
drop down list
Can I know how to make a new data that we enter under the AddItem method to be saved permanently in the drop down list?
how combobox loads data from access table
hi
i really really need your help..i'm using vb 2008 n connected it to access 2007.
how can i get the combobox to load data from the access table ??
thank you!
Combox Itemdata in run-time
Hi,
I use a ADO recordset to fill a combobox with a TEXT (an Address form in SQL to be 1 field) in the list and ID in the itemdata on the form load.
I got a command button that popup and other form for either modification of current seleted address or a creation of an new one.
on that
I build an Form object,
verify if it was saved, then clear the combobox and rerun the Recordset to reload address list of my customer,
If I run it in step-by-step, the combo box reload with modified list correctly, on run-time : it will not update correctly.
I used combox.clear to clear the list, and reload it with recordset.
can someone explain to me why it works on step-by-step, but not in real time ?
Regards
How can be send data of one form to another form?
Sir,I am beginner of vb6 programming.I need help on this topic.Pls help me..........
when you're using combo box
when you're using combo box ... then you choose one... in the list how do you diplay it on the display label.... pls need help
COMBO BOX WITH AUTOCOMPLETE FILEN NAME
HIGHI EVREYBODY
I Need Code OR ActiveX COMBO BOX WITH AUTOCOMPLETE FILE NAME LIKE WINDOWS RUN DIALOG OR EXPLORE ADRESS
THAK YOU
Stop AutoSelection
I am having a problem with a combobox and entering the string with a bar code scanner.
It appears that the issue is being caused by the selctions being added into the display box as the string is added by the bar code reader. I want the string added to the input box without the selections from the list at least until the string is complete. Is there a way to disable this autocomplete or list selection complete?
Using a combo box in a calculator
Hello all, hope some one can help me? I'm trying to use a combo box in a calculator. There are two text boxes that are to be multiplied and a third box shows the answer. So if the input to text box 1 is 2 and the input to text box 2 is 6 then normally the answer would be 12. Text box 1 & 2 are to have combo boxes placed next to them to show units i.e. micro, milli, centi, kilo & mega. So if text box 1 uses milli units and text box 2 uses mega units the answer then will be 12000 (0.002 x 6000000). I'm not sure how to assign the units to the text box so the user can type 2 in and then select milli from the list of units to achieve the required answer, can anyone help? Thanks
related to combox
i do need some help related to combox:
1) m making my project and in that have used combox for selecting various options and had inserted the item , suppose i had entered MBA, BCA, MCA, B.E.
in the begging i have used database to enter marks per semester(i.e. upto 8th sem) now my problem arises that some have courses for 3 year(means upto 6th sem) some have courses for 4 year(upto 8th sem) how to disable the text boxes which have course upto 3 year only or less.
2)how to restrict the marks to be entered upto 100
Do help me with relevant code.thnx in advance
MoveWindow
In case anyone runs across this, the MoveWindow API doesn't work properly when moving a combobox on the SSTab control.
http://www.xtremevbtalk.com/showthread.php?p=988558
http://support.microsoft.com/default.aspx?scid=kb;EN-US;187562
These articles do not hit on the problem directly, but give you an nudge in the right direction.
I ended up just storing the
I ended up just storing the .Top and .Left of the ComboBox and the last thing the procedure does is set the .Top and .Left of the control back to the original.
i need a code for
i need a code for automatically detection of peripherals attach(i.e printer,scanner)can you help me?
thanks
.net
i want to no hw to write for combobox
how combobox loads data from
how combobox loads data from access table and how we can enter another text under combobox data in same table. plz tell me how it done .
thanx in advce
list box or combo box with pull down menu
I have a working VB program but I need to add a selection of items that can be selected by the operator. I do not have to be able to enter any new items in the list only select from the list. I would like to only show one line on the form to save space and when the list box is selected then I could pull down the rest of the box so I could see all the members in the box. I cannot seem to understand how to do this. Can you help me? Once an item is selected I want to set a paramter associated with that item so I can use it for look up later.
Thank you
adding the value in the itemdata
Hi, I've just read your combobox information. the question that I have is it possible to add the value of index . like with the lines below .
cboFood.AddItem "Orange"
cboFood.ItemData(cboFood.NewIndex) = 60
cboFood.AddItem "Apple"
cboFood.ItemData(cboFood.NewIndex) = 80
cboFood.AddItem "Banana"
how can I add the value in cboFood.ItemData(cboFood.NewIndex) = 60 and the value in cboFood.ItemData(cboFood.NewIndex) = 80 together and store it in another variable. thanks
abt combobox
plz help.....i hv to develop one govt project..in tht m using two comboboxes....both wl be connectd to access....through adoc i hv connectd...in the output if i select taluk name in the first combo....autometically it has to display villages tht r cmng under tht taluk....but it is displaying all the villages tht r in table.....i need solution for tht.....tel me hw to use filter property for tht.............
thank you
index in combobox
Do index in combo box have maximum limitation in case we always add item to them and never clear ?
Pls i need a help
I created a database with access 2007, how can i retrieve my data through adodc in vb6, it's giving me error about the file format not supported and i don't know where to get access 98 to create the database
re
HI.
You can in Microsoft access change database format do access 98.
Tools/Database Utilities/Convert Database.
Vlad
how combobox loads data from access table
how combobox loads data from access table and how we can enter another text under combobox data in same table. plz tell me how it done .
thanx in advce
come on budy.....................
HI, i need to know if this
HI,
i need to know if this is possible
combobox1(select an item/word)
||
Access(searches for a database that matches the selected item/word from the combox1
||
combobox2(matched items/word from access are the only ones being displayed)
Need help, thank you!!!
yes, have the same problem.
yes, have the same problem. except mine need to use VB6.
Also want to know if once matched, can it automatically in a notepad or another access database then print it as a datagrid?
those who can help, thank u. I appreciate it very much
combobox in vbnet
hello, can anyone help me with my project in vb.net. My teacher asked us to create a vb.net project using 3 combo boxes. One for month, date and year.
then there will two labels that will display the zodiac sign and the astrology year selected from the combo boxes. i really don't know the code so please help me, I will appreciate your response very much..
If there are a lot of combo
If there are a lot of combo boxes on the form. It’s also not efficient for high speed data entry, like using TAB to move through controls and the number pad or arrow keys to select answers. With just a few lines of code, you can make your combo boxes drop down automatically when the cursor enters them. I’ll show you two ways to accomplish this..
hi!
thank you!!! because of you one of my thesis prob is solved love lots! and godbless! godspeed !
Thank you very much for
Thank you very much for sharing your valuable resources....
combo box
i have a project in that 2 combo boxs are there . In first combo box 3 options are there under each option five sub options are there when i want to select first option the five option should be display in second combo box . When i select the second option that five sub options should be displayed in second combo box. Sir Reply me.
MoveWindow
I placed an SSTab on a form, dropped a frame on the first tab and then placed a combo box. When the Call MoveWindow(pobjCombo.hwnd, pt.X, pt.Y, pobjCombo.Height, lngNewHeight, True)
code is executed from the SetDropDownHeight sub, the combo box is totally displaced. Any suggestions to keep the top and left as-is? Thank you.
very useful
very useful tutorial
basically i was looking for such functionality in my project, and now i am thinking that my surfing time is utilized.
thank you very much
Very helpful for amateurs
Hi,
This tutorial is very helpful for amateurs like me. Thanks a lot.
How to display a corresponding Text of combobox to lable
I could open the database and recordset.
now on combo1_click() if I'll select the particular item then the corresponding value of that particular item should be displayed on lable.
can any help me?
Thank You!
This tutorial helped immensely, esp. the combo height function.
combo box and list of cars
can u please help me making a combo box of a different kinds of cars? like toyota and ferrari?
i dont know how to make it..... please......................... i really need some of help....
Wow! Search-As-You-Type
Wow! Search-As-You-Type ComboBox (Enhanced Database Example) tutorial works like a charm!
Thank you!
Unblocked Proxy Sites/Online Horror Games
Thank so much!!!
Thank so much!!!
Combo box
Pls.help me. I want date,month and year in the combo box which is used in my project.
i want code of these combobox.
u cant use combobox for
u cant use combobox for date, time & month...
use datetimepicker....reference microsoft windows commom controls 2.6 library...
its very easy..
vb 6.0
i made a logIn form,using adodc with access. My problem now is How can I call my username in my password so that i can logIn to my form.i done creating my username and passwordand save it to my database.plessss help me
Good
Well this is the perfect place to know abt VB if someone new to VB programing...
Thanx 4 help, thanx a lot.
Thank yoiu very much. you
Thank yoiu very much. you help me a lot
Excellent
thanks for this. I overthink everything...good job
combo box error
i got a problem everytime i click a record in a listview and display it in the combo box. the property of combo box is set to 2- drop down and at first, it was fine but the second time i click a record, this error appears. pls help..thank you.. : )
P.S. The error says, run time error '383' = 'Text' property is read only.
I have this line of code in my program :
cbocat.Text = mnulist.SelectedItem.SubItems(4)
please help me fix this mess. Thanks a lot...!
combo box error
i got a problem everytime i click a record in a listview and display it in the combo box. the property of combo box is set to 2- drop down and at first, it was fine but the second time i click a record, this error appears. pls help..thank you.. : )
Add Items From Database in Combobox
Hi guys,
I am doing a project where i need to add items to a combobox from the database....only one field. Hows do i do it? Please Help!!! I am using Data1.
add item in combo from database
Private Sub Form_Activate()
Do While Not rs.EOF = True
Combo1.AddItem rs.Fields("cid") 'cid is the name of the field in access table
rs.MoveNext
Loop
End Sub
instead of "cid" u can enter ur field name that to be added in ur combo
combo box in datagrid column using vb
how to display combo box in datagrid for perticular column using vb.
Very nice
Very nice
welll done
ha.ha . this helped me alot becouse it hight quality tutorials
search as you type combobox
it helps me a lot....
excellent...i have learned now how to use it...
The Multi-select combo box -
The Multi-select combo box - excellent work. I keep finding people who just say "it isn't possible, use a list box"
combobox
pls help me. how do i bind a ms access field to a combo box? i need to put several items (1750 items to be exact) on a combo box. tnx.
COMBOX BOX
HOW TO USE COMBO BOX IN PROCEDURES
PLZ GIVE ME A EXAMPLE CODE ON MY EMAIL ID :
SRIVASTAVASHAUNAK@GMAIL.COM
how to upload photo in vb6 program
guys help me to upload photo in vb6...
how to conect combo box in the database access
guys please help me in my program in vb6, how to conect my combo box in my database access?please help me..godbless..thanks
great
great men.... keep up the good work.. it helps a lot to me....
Excellent Tutorial
Man,
pretty happy I found this post after searching through lot of useless tutorials. As many had said, this example fully expains how combo boxes work. Most of the other posts only partly shows how combo boxes works. I have 3 excel books and non of them clearly explains the combo boxes either.
Again, fully appreciate your work.
Thusitha
Thanks for coding "combobox as we type"
i was looking for such a code but you have solved my problem and have saved so much time to waste.
thanks
thanks for coading sir you r save my so much time
tabale
sir
i have tabale product & price, if i select combolist product then product sow ,but product amount is no foucs on my texbox,(
plese somone cane hep me
How to switch from vbComboDrop-DownList (value = 2) to simple
Ho How to switch from vbComboDrop-DownList (value = 2) to simple vbComboDrop-DownList by code please answer me
Combo Box-
...excellent material, especially for a novice... Highly recommend.
Reallly an AWSOME post,
Reallly an AWSOME post, Thank you very much, This has helped me a LOT!
Thank you so much!
I don't usually post replys, but I had to thank you for saving me a bundle of time with your code. Thanks for posting your hard work to help out the rest of us.
combo of vb6 with ms access database
I have two table in MS Access
country master(country_id primary key,country_name char)
state_master(state_id primarykey, country_id, state_name char)
country_id is referientail in state_master
I want to make two combos
plz tell me how can i mak second STATE_COMBO
when i select name of the country from the first COUNTRY_COMBO
then STATE_COMBO should automatically display only that state name which is related to that country
I have two table in MS
I have two table in MS Access
country master(country_id primary key,country_name char)
state_master(state_id primarykey, country_id, state_name char)
country_id is referientail in state_master
I want to make two combos
plz tell me how can i mak second STATE_COMBO
when i select name of the country from the first COUNTRY_COMBO
then STATE_COMBO should automatically display only that state name which is related to that country
Combo of vb6 with ms access database answer
You need to change the rowsource properties in the STATE_COMBO box. First though create an unbound text box on your form. Give it a name in the such as cboCountry. Now in the unbound text box you need to reference the dropdown first column control, ie in the rowsource just type in =[cbocountry]. Check in your form now to see if each time you click the first drop down that the unbound text that you bound to =[cbocountry gives you the bound value to your table].
Secondly here the tricky bit
Go to the properties of the STATE_COMBO box an click into the build properties of the rowsource. Add the fields that you want to show in the STATE_COMBO and ensure you add the foreigh key or many side key to the build sheet. Now for the criteria you basically want to build criteria to make the foreigh key match your =[cbocountry].
You also need to requery the second combo box with the afterupdate event from within the first combo.
This way you can always ensure that the second combo has the correct states for the country just selected.
Need any further help just ask.
Chris.
ComboBx to Lable via Dbase
Would u plz tell me?
I could open the database and recordset.
now on combo1_click() if I'll select the particular item then the corresponding value of that particular item should be displayed on lable.
can any help me?
Combo boxes
I especially like the fact that your tutorial is intensive an gives one the oppotunity and expertise to create their own powerful programs in VB using Combo boxes
Post new comment