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

Combo Box

Status
Not open for further replies.

Baixinha

Programmer
Dec 27, 2000
122
BR
I created a consult form and to consult, I need to have a combo box with all of titles to consult.

How can I add this items from database to combo box?


 
If the names are in a table of their own, just put the table name in the combo box's Row Source property, set the Row Source Type to Table/Query, and set the Column Count, Column Widths, and Bound Column properties.

If the names are in another table, where they may occur repeatedly, create a query on that table that selects the consult name. Set the Unique Values query property to Yes. Then use the query in the combo box's Row Source instead.

If the names aren't in a table at all, you can set the combo box's Row Source Type to Value List, and type the names in the Row Source property, separated by semicolons (";"). Rick Sprague
 
Dim db As DataBase
Dim dbname As String
dim rs As Recordset

dbname = app.path & "\mydatabase.mdb"
Set db = Opendatabase(dbname,False,False)
Set rs = db.OpenRecordset(" Select name,* From MyTable ",dbOpenDynaset)

do while not rs.EOF
combo1.AddItem " rs!name & ""
rs.MoveNext
Loop

Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
if it's a dynamic range you will need to populate it on open or at some time via a macro.......i can show you how to use a multi-column combobox with dynamic ranges if necessary......if u need help email me at:

drat@mediaone.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top