Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Visual Basic

See Related Forum Messages: Follow the Links Below to View Complete Thread

Populate Combo Box Based On Users Selection From Previous Combo Box.
I have 2 combo boxes. The first combo box contains the product names that i have pulled from an Access2000 database as follows:

Set rs = db.OpenRecordset("Products")
Do While Not rs.EOF
  cmbPName.AddItem rs.Fields("Name").Value

I have a second combo box that i want serial numbers to be listed in based on which product the user chose from the products combo box? When the user selects a product, then the second combo box is populated with serial numbers? The products are in the products table and the serial numbers are in the serials table the tables are joined by product id. I've tried everything and i can't get it!

Thanks in advance!!!

Populate Combo Box
I'm trying to populate a combo box using a table column in SQL server. What is the proper syntax to make the call to the database table/column name, and fill in the list of the combo box? Do I need to use an OLE control?

Any tips or direction would be helpful.

Populate Combo With Dir
Access 2000...

With the help of someone on this forum, I was able to populate a combo box with the filenames in a given folder.

There appears to be a limitation however.

Here is the code......

Private Sub Form_Open()
'Code to populate project report combo box with directory contents
Dim str_filename As String
Dim str_filenames As String

' Change folder path below as desired:
str_filenames = Dir$("c:windowsdesktop*.*")

str_filename = Dir
str_filenames = str_filenames & ";" & str_filename
Loop Until str_filename = ""

cmb_filenames.RowSource = str_filenames
cmb_filenames.Value = Mid$(str_filenames, 1, InStr(str_filenames, ";") - 1)

End Sub

As this code is written, it will run fine, but change the directory to say, C:windowssystem it dies because the directory is chock full of files.

The code works until the directory exceeds X number of files. What that exact limitation is, I don't know. Maybe it's a limit on the number of characters allowed in a string. Again, I don't know.

We already have more files in the folder on the server than the code can handle, and we add a couple more every week.

Is there a way around this? What I am trying to do is allow the user to open the Word document associated with a particular record.

The other approach I tried was creating a table of the directory filenames which we will have to manually update. This extra step is acceptable, however, using SHELL fails because of spaces in the directory path and spaces in the filenames.


Populate Combo

I have a combo with a list of locations in it. This is gathered from a query embedded in it. I have a varibale with an ID in it that will match to my combo's column 0. What I would like is for when the form loads, the value which matches the varibale to be displayed in the combo?

I cant get this to work? Help if anyone knows. Please!!

Populate A Combo Box
I have set up a connection with Access database.

I need to populate a combo box on the form with a list of names found in the database.....

How To Populate A Combo Box?
how to populate a combo box with data from a access database

this is what i have currently...........

Private Sub cboTraineeId_click()
'Set cn = New ADODB.Connection
'cn.Open "Trainee"
'Set rs = New ADODB.Recordset
'rs.Open "Select field from table", cn, adOpenKeyset
'If rs.RecordCount > 0 Then
'Do While rs.EOF = False
'cboTraineeId.AddItem rs!Field
strData = "Select * From Trainee Where Trainee ID = " & cboTraineeId.Value
End Sub

Populate Combo Box
I have this code to populate a combo box, but I want to be able to add items
in the form I can add items, but when I save and exit, return to form anythng new I add is not there, just the items in the code.

Private Sub Document_Close()
Dim stext As String

stext = ComboBox1.Value
Me.CustomDocumentProperties("Seltext") = stext
End Sub

Private Sub Document_Open()
Dim oProp As DocumentProperty
Dim iCtr As Integer
Dim vtext, vtexts
Dim bPropExists As Boolean

vtexts = Array("first item", "second item", "third item")

For Each vtext In vtexts
ComboBox1.AddItem vtext

' Check if property exists
If Me.CustomDocumentProperties.Count > 0 Then
Set oProp = Me.CustomDocumentProperties.Item("Seltext")
If Not oProp Is Nothing Then bPropExists = True
End If

If Not bPropExists Then
' Add property to collection
Me.CustomDocumentProperties.Add "Seltext", False, _
msoPropertyTypeString, "first item"
' set default selection
ComboBox1.ListIndex = 0
For iCtr = 0 To ComboBox1.ListCount - 1
If ComboBox1.List(iCtr) = oProp.Value Then
ComboBox1.ListIndex = iCtr
Exit For
End If
End If
End Sub

Populate 2nd Combo Box
I have one combo box that lists some data from my access database. When the user selects a item I want a second combo box to automatically select the record that matches with it. I have tried but I don't think what i am trying is correct.

Any help is greatly appreciated.

Private Sub cboRubric_Click()
'populate cboCourseTitle with matching record
Dim rsTitle As ADODB.Recordset

Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "catalog.mdb"

Set rsTitle = New ADODB.Recordset

Dim sSQL As String
sSQL = "SELECT CstCourses.Course FROM Degrees INNER JOIN CstCourses ON Degrees.DegreeID = CstCourses.DegreeID WHERE CstCourses.Rubric = '" & cboRubric.Text & "'"
' Query database
' Populate cboStates with resulting State names

rsTitle.CursorType = adOpenDynamic
rsTitle.CursorLocation = adUseClient
rsTitle.LockType = adLockPessimistic
rsTitle.Open sSQL, strConn

'pass matching records
Set cboTitle.DataSource = rsTitle

End Sub

Populate Combo Box
I have selected field name that populate into combo box in form1.. How I can sent this selected field name into combo box in form 2 ?

Populate Combo
How can i populate a comboBox with data from database? using ADO?
I tried using DataCombo but getting some problem, so want to populate the combobox with code....


Populate A Combo Box
How do I populate a combo box with data from a adoc connection object?


Populate My Combo Box
I am trying to populate my combo box when I load or activate the form. When I load the form it just hangs.

What is wrong?

Private Sub Form_Activate()

Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sql As String

sql = "SELECT * FROM ComboCategories "

conn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & App.Path & "dbGraphics.mdb;Persist Security Info=False"
conn.CursorLocation = adUseClient

rs.Open sql, conn, adOpenStatic, adLockOptimistic

With rs
Do While Not .EOF
cbCategory.AddItem .Fields("Categories")
End With

Set rs = Nothing
Set conn = Nothing

End Sub

How Do I Populate A Combo Box
I have a combo box that pulls data from a database table and works fine.
My table looks like this:

field1 field2 field3
37 0.397 0.399 0.402
37 0.392 0.396 0.408
37 0.397 0.412 0.403
37 0.397 0.476 0.403
38 0.398 0.452 0.403
38 0.398 0.409 0.403
38 0.398 0.402 0.404
38 0.398 0.401 0.404

The problem is, I only want the combo box to display one instance of "field1". For example, I want 37 to be displayed only once, instead of twice, and 38 once, and so on...

THANX for any help on this!!!!

Populate Combo Box
I am trying to populate my combo box with the field companyname from my company table in SQL.

Any ideas anyone?

Populate Combo Box
hi, i am populating a combo box based on selected criteria.

it works ok, my input data for this combo box have different format/length, for example CYP or CYPRESS. now it shows both variants and i want it to show just first 3 characters (CYP).
any advice, please?

here is my existing code:


    sSQL = "Select SPEC From " & "LD" & cmbMONTHS.Text & "  GROUP BY SPEC Order By SPEC"
    Set RSACCESS = New ADODB.Recordset
    RSACCESS.Open sSQL, objAccessConnection, adOpenKeyset, adLockOptimistic

    While Not RSACCESS.EOF
        cmbSPEC.AddItem RSACCESS("SPEC")           

How Do I Populate A Combo Box Using DAO And ADO
I'm new to VB and I'm trying to Populate a Combo box from a
Ms Access 2000 MDB.  I'd like to get an example of how to do this using both DAO and ADO  using the ODBC.



How To Populate A Combo From Excel To
I have a control on a form in I have created my references to the excel object.

I want to populate my combo with data from 1 column. In excel the combo had a property called rowsource and I could go mysheet!A2:A627 and it would populate the combo.

I am not sure how to do this in .net do i really have to go through each row adding each item to the combo with .add method?

regards in advance
dover UK

Populate Combo Box With Times
Hey, I need to populate a combo box with times for use with an appointments program. The times will need to be in the format h:mm AM or PM, eg, 8:00AM and increment in 30 mins. So for example start at 6:00AM --> 6:30AM --> 7:00AM, etc. and finish at about 8:00PM. Can anyone show me how I can do this? Thanks

Populate Combo Boxes

Here is my code

Private Sub cmbProgram_Click()


CurrentProgram = frmDeleteSerial.cmbProgram.List(frmDeleteSerial.cmbProgram.ListIndex)

Dim ws As Workspace
Dim db As Database
Dim rs As Recordset

Set ws = CreateWorkspace("Add Program", "admin", "", dbUseJet)
Set db = ws.OpenDatabase(App.Path & "serialkeygenerator.mdb", , False)
Set rs = db.OpenRecordset("tblProgram")

Do While rs.EOF = False
If CurrentProgram = rs!ProgramName Then
ProgramID = rs!ID
End If

Set ws = CreateWorkspace("Add Program", "admin", "", dbUseJet)
Set db = ws.OpenDatabase(App.Path & "serialkeygenerator.mdb", , False)
Set rs = db.OpenRecordset("tblSerial")

I = MsgBox(ProgramID, vbOKOnly)

If Str(ProgramID) <> Str(rs!ID) Then
frmDeleteSerial.cmbSerial.List(frmDeleteSerial.cmbSerial.ListIndex) = rs!ID
End If
I want to populate two separate combo boxes,,,,the first with all the programs in a table, then when a specific program is choose, i want to populate the second list with all the serial number associated with it. any suggestions?


Populate Combo From Flex ?
I have got 2 comboxes and a flex with 2 columns.

On the DropDown event of either combo box I pass a parameter thru and sort the flex accordingly.
I then populate combo 1 with column1 data from the flex, and combo 2 with column2.

To do this I am loop reading thru the flex and re-populating the combos.
Is there a quicker way of populating the combos than reading thru the flex 1 row at a time ?

Just thought I would ask the question as a quicker way would be nice

Combo Box To Populate A List Box
Hi, any help would be appreciated on this one...

I have a combo box populated with dept names and i want it to populate a list box underneath it with the corresponding employees who work there...

this is in my form load to set the RS:

strName = cboUnitName.Text

With rsUnit
.Open "SELECT * FROM UNIT", cnEmployee, adOpenStatic, adLockOptimistic, adCmdText

End With

Do Until rsUnit.EOF

cboUnitName.AddItem (rsUnit![UNIT_NAME])
MsgBox (strName)



Then under the change event of the combo:

With rsUnit

lstUnitMembers = rsUnit(0)
MsgBox (1)
MsgBox ("opened")

'lstUnitMembers.AddItem ([EMP_LASTNAME])

'= rsUnit![EMP_LASTNAME]

If .EOF Then
MsgBox "Record not found", vbExclamation, "Search"

End If

End With


So in there somewhere, i don't know how to add the names into my listbox lstUnitMembers... any ideas?

How To Use An Array To Populate Combo?
I have several combo boxes that are in an array. How can I populate them all with the same list?

I use this code to populate one:

PHP Code:

Private Sub Form_Load()
Data1.RecordSource = "SELECT * FROM CustomerList" 'Filter Fields with a unique Name
Data1.Refresh ' Refresh The Table
While Not Data1.Recordset.EOF
Combo1(0).AddItem Data1.Recordset("Employer") 'Field on SELECT
Data1.Recordset.MoveNext ' View all Field Content

End Sub

Populate List Box From Combo In DAP

I have a combo box and a list box , i have created in Data Access Pages , i want to populate the values of the listbox by selecting a value from the combo box , then after the values are populated in the list box , i want to choose a value from it and then goto another DAP where i can edit that record.

It does not populate the values for the listbox at all...
I have the code , it works fine in Forms but when i do this is DAP it does not work at all it gives me errors that makes no sense... below is the code ( i did not write this code bymyself but took it from somewhere) , its been 3 days now but i just cant get it to work anyway , anyone just show me the way (i have no experience in Visual Basic):

On the Combo box's onafterupdate property:
If IsNull(Me.cboPlants) Then
Me.cboUnits = Null
Me.cboUnits.Enabled = False
Me.cboUnitsLocked = True
Me.cboUnits.Enabled = True
Me.cboUnits.Locked = False
End If

On a Button to generate the results :
Dim rownum As String
Dim myfilter As String
If Me.[cboUnits].ItemsSelected.Count = 0 Then
Exit Sub
Else If
For Each rownum In Me.[cboUnits].ItemsSelected
myfilter = myfilter & "[Plant ID] = '" & Me.[cboUnits].Column(0, rownum) & "' OR "
Next rownum
If Right(myfilter, 3) = "OR" Then
myfilter = Left(myfilter, Len(myfilter) - 4)
End If
DoCmd......(i could not open another record in DAP at all)

best regards,

Sorting To Populate A Combo Box
Hello all
I have written code that that will sort the data from two arrays and then supply that choice into a combo box
I have two files one with a list of vehicles for hire (recVehicles) and another with bookings already made for these vehicles (recBooked) the vehicles have unique ID numbers given to them
Some of the vehicles require the client to be over 21 years of age and therefore I have used a sort to firstly establish which vehicles the client can have once this is sorted I then compare the ID number of the vehicle to the ID number of the vehicles in the recBooked array to see whether this car is booked out for the date the client wants, if the vehicle is booked out that date then the program will not enter this vehicle into the combo box for the client to choose, if the vehicle is not booked out the program will loop and check the next booked date with that cars ID number if all the dates are not the same as the clients date then it will place it into the combo box and try the next vehicle in the recvehicle array and repeat.

The code below I have written will populate the combo box with the vehicles available for that date and within the clients age range, however the problem is that it will populate the combo box twice with every available vehicle instead of once.

I know that this is a problem with the counter in the program but cant work out a way round it without effecting the program
Any help with this will be great
thanks chris


Private Sub cmdPopulate_Click()
Dim intNext As Integer
Dim bolCheck As Boolean
Dim intNew As Integer
bolCheck = True
intNext = -1
intNew = -1
Do While intNext < intNovehicles
    intNext = intNext + 1
        If sinAge < 21 And recVehicles(intNext).strLicense = "Over 21 Years Old" Then
            bolCheck = True
            bolCheck = False
        End If
        Do While bolCheck = False And intNew < intNobooked
        intNew = intNew + 1
        If recVehicles(intNext).strID = recBooked(intNew).strID Then
        If mskStart < recBooked(intNew).strBookedend Or mskEnd > recBooked(intNew).strBookedstart Then
        bolCheck = True
        intNew = -1
        bolCheck = False
        End If
        End If
If bolCheck = False Then
cboHirelist.AddItem recVehicles(intNext).strID
End If
End Sub

Populate Combo With Directories
so i am trying to make a program to organize all my dvd ripped tv and movies.
i have a form with an embedded wmp. all my videos are organized on my desktop like this:

     >movies>"all my movies"
                       >tv>two and a half men>season1>"all season 1"
             >season 2>"all season 2"

so for tv i want a combo box to display all shows under tv, then another to pick season (but only if i have the directory for that season), than a list box with all the shows from that season.

for movies i want a combobox with all the movies in that folder preferably without the .ext
i have no code as i do not know where to start. if anyone has a simple solution i would be greatful.
i did try this but its all wrong

combo1.additem (directory.getfiles"c:/user/desktop/videos/movies/")

i got it off another site but as you can guess it just adds directory.getfiles"c:/user/desktop/videos/movies/" to the combo
i have encluded a dummy exe to show exactly what i am doing.

Edited by - spheresoft on 5/16/2008 2:56:06 PM

Populate A Combo Box From InI File
I am able to read my first entry in the INI file and add it to the combobox but can't get it to loop to get the next line. If anyone has a piece of code to read an INI file and populate a combobox that i could use that would be great.

The code can't just read all the data in the file because I'm using the file as a configuration file so there will be other items in there under different sections. Example of file


So I want to populate the combobox with the User section entries only.

Thanks for all your help in advance

Edited by - skeeley6 on 12/1/2005 1:56:19 PM

Populate Combo Box W/ Certain Criteria?
Is it possible to populate a combobox with certain data when data is selected before it?

Here is an example:

I have two combo boxes, one for Month and one for Day. What I want is the Day combo box to populate all the months with 31 days when a month with 31 days is selected, same for 30 days, and same for the one month with 28 days. (Basically, if you select January in the combo box, I want the Day combobox to be populated from 1 to 31) How can this be achieved with VB? I know it's under my nose but I just can't figure it out...

Also, how can I make it so that a user can type in a selection that is in a combobox? (For instance, if selected A, B, C or D, and the user wanted to type C - it would select C and move to the next event. I have a combobox set up that when you select something with it, it will enable the next one, but if I just type in the value, it won't do anything until I actually click the down arrow and select the letter manually.)

Edited by - JMan0948 on 11/16/2004 6:03:11 PM

Populate Combo Box With Db Data
I am new in using VB. Can some body help me how to populate data in combo box. I am using Msaccess and wanted to populate data from one of the feilds of my query.


Populate Combo And Lists
Working in Access:
I would like to populate (initially empty) comboPartners, comboResponsibles and lstAvailable with data from queries qryPartner, qryResponsibles, qryOthers, respectively, on selecting an item from comboDepartment.

That is, in algorithmic format:
on selection comboDepartment
run qryPartner
populate comboPartners

run qryResponsibles
populate comboResponsibles

run qryOthers
populate lstAvailable

can anyone help on this? Thanks

Does someone also know how to empty all controls (re-initialise) on form Load?

Thanks, Merci, Dank u, Shukriya !!!

Populate Date In Combo
Hi, All.

Anyone has experience to populate date in combo for a year, let say the format of date is in "mmmm yyyy". So in the combo when I click will be listed January 2005, February 2005 and so on.

Thanks a lot.


Populate Combo Box From A Recorset
I want to populate a Combo Box from a recordset (I want to list every values of a column).
Thanks ! :-)

Populate A Combo Data
Here is my problem:
I have data in dataenvironment1: "Route" and "Troncon"
Suppose I choose a "Route" = 20 in a combo data in a form. I want all the "Troncon" that are related to "Route" = 20. So I have to make a query in the module Route_LostFocus but I'm not able to affect the data to the comboData "Troncon". I tried:
Me.Troncon.RowMember = DataEnvironment1.rsGlissiere.Fields("Tronçon")
Me.Troncon.ListField = DataEnvironment1.rsGlissiere.Fields("Tronçon")
and I affected to the property RowSource DataEnvironment1 (where my data are)

but it doesn't work!!!

Data Combo Populate
I'm not sure about how easy this is, but Is there a way to populate fields of a record by selecting the info from a data combo control? For example, say the data combo is filled with company names. By selecting one of those company names all information from the company table will automatically come up on the form so that the user will not have to type the information themselves. Can this be done and how? I would appreciate any help at all.

Populate A Combo Box With Word Doc Filenames
i have a combo box on my form. when the form loads i want the combo box to be populated with all of the word documents (filenames of the documents) in a folder called "C: est". i'm not sure where to start.

can anyone give me any ideas.

thanks for the help.

VB6/VBA - Populate Combo Box In Powerpoint Presentation
Hello everyone,
I have a powerpoint presentation. On one of my slides, I would like to add a combo box. I would like to populate the combox box with some values.

Where and how do I put in the vb or vba code in designing this presentation?

How do I go about populating this combo box with my values?

Note: I want this combox box to be operational when I run the presentation.
This is a new gig for me, so a clear explanation will be much appreciated.

Dynamically Populate A List Box Or Combo Box
I am back with what I hope is a simpler question.
What is the best way to dynamically populate a list box or combo box with the contents of a folder and then let the user select an item from this list?

Populate A Vb6 Combo Box From An ACCESS Table
Hi, in my program i can add students to a database. On another from in VB6, is it possible is populte a combo withthe new student from the access database,

Or do i have to enter it manually?

Chris Lynch

Populate Database Tables In The Combo Box
I don't know how to start. I have combo box and 2 tables store in the Microsoft access database. My question are

How to populate 2 database table into the combo box ?Most sample is populate the field name, or populate the field value.This time I would like to populate 2 database table so that I can make a query from selected tables.have an idea for starter and sample code to learn.

Populate Field Names(combo Box)
I used to know this code, it is soo easy.
I believe you set a integer, and then you loop through the data until all the fieldnames are in the combo box? and set your eof properties?

Thanks for the help.

Populate A Combo Using Access Database
Can anyone give examples of how to use vb to populate a combo box from a table in an access database.

I've used MSRDC control to add information from my form into the access database, how can i use MSDRC to populate my combo?

i've tried something like this...but doesnt work

VB Code:
Private Sub Combo_senders_code_Change() combo_senders_code.Clear Form3.MSRDC1.SQL = "select * from awb where combo_senders_code = '" & combo_senders_code.Text & "'"Form3.MSRDC1.RefreshForm3.Show  'rsfields.MoveFirstDo While Not rsfields.EOFcombo_senders_code.AddItem rsfields("Shortcode").valuersfields.MoveNext Loop

Im very very stuck.!

Populate Combo Box With Files In A Folder
Dear All,

i am using vb6. i want to populate a combo box with files in a folder.
i want to recgonize the changes made by others from vb.
those are ..
adding new files to a folder,
moving or deleting existing files in a folder.

Thanks in advace

Populate A Combo Box With Results From SQL Query
I'm not sure exactly how to go about doing this. I was hoping the SQL would be something like:

VB Code:
"SELECT gameid FROM game WHERE hometeamid = " & Text1.Text & " OR awayteamid = " & Text1.Text)

That doesn't work, doesn't like breaking the "" like that. So basically, what I'm doing is creating a recordset from one table (team). The values are displayed one at a time in a textbox (Text1). A command button is used to browse through the values. I would hope that I could populate a combo box with the value(s) in another table (game) that matched the Text1.Text. Is it clear what I'm asking for? I'm not even sure if I know what I'm talking about. Anyway, if somebody has an idea of what I'm looking for I'd appreciate it. Thanks

Auto Populate Combo List
How would i Auto populate a combo box with a list of all the PCs that are on the network??

How To Populate The Combo Box Using MySQL Database
using VB and Mysql Database

is there any possibilities to retrieve tables information to display on the combo box for user to choose ??

for e.g brand. there are alot of different brand store in the database brand table.

i wanna retrieve all the different brand to display in the combo box and user should be able to add new wordings to the combo box as well if it is a new brand which is not found in the database

wat should i do can give any hint... or e.g for me ..

Populate Combo Boax From Access
Hi everyone.

Can anyone please tell me how to populate a combo box from an Access


How Do You Populate A Combo Box With A Filed From A Database
I have a table called Customer, with an attribute called CustomerLastName.  How do I populate the combo box with the last names from the database into the combo box.

Trying To Populate The Values In A Combo Box By Calling Another Sub

I am designing a program that has combo boxes on various forms which will all contain the same values. It seems logical to create a sub which populates those values and call that subI tried to do it on a basic form which has a combo box on it. The code below is what I wrote. When I try to run the program I get an error "Object required" and highlights the line "textmessage.clear".

I thought my logic was sound, but it isn't working. Can someone please point out to me where I am going wrong.



Option Explicit

Public Sub dropdown(textmessage)

        textmessage.AddItem "Eggs"
        textmessage.AddItem "Bacon"
        textmessage.AddItem "Cheese"
End Sub

Private Sub Form_Load()
    Call dropdown(Combo1.Name)
End Sub

How Can I Populate Combo With Project Forms
Dear All,

i need to pupulate my combo with my project Forms
Can any one help me with some line of codes,



Populate The System DSN In ODBC Into A Combo Box
How can I populate the list of system DSN in ODBC into a combo box?

Also, is there any utilities I can use to compare (get the rows that do not match) the tables of 2 databases (using different ODBC connections). The table definitions are 2 databases are the same.


Copyright © 2005-08, All rights reserved