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

How to populate a DBCombo without data controls?

Status
Not open for further replies.

1forino

Programmer
Apr 26, 2001
14
PT
Hi,
I'm making an application in VB6 and a database in SQL SERVER.
I'm triyng to populate a dbcombo with code, without data controls.
With property datasource, no problem. But how can I do with rowsource?
Thanks in advance for any tip.
 
I think I know what you mean as Itoo have had to populate many combos without the use of data controls, however I only used simple bog tsandard combos. The code was something like

devBoundControls.tblTable
20 With devBoundControls.rstblTable

30 If Not .EOF Then
40 cboName.Text = .Fields("FieldID")
50 End If
60 While Not .EOF
70 cboName.AddItem .Fields("FieldID")
80 devBoundControls.rstblTable.MoveNext
90 Wend
100 End With
110 devBoundControls.rstblTable.Close


This got a recordset froma data environment and then looped and populated the combo
 
I hope the linenumbers were just a joke. :-D
Also in your example, If the user selected the drop down list type of combo, you will need to populate the list before you set the text otherwise a error will occur.

devBoundControls.tblTable
With devBoundControls.rstblTable
While Not .EOF
cboName.AddItem .Fields("FieldID")
devBoundControls.rstblTable.MoveNext
Wend
.movefirst
cboName.Text = .Fields("FieldID")
End With
devBoundControls.rstblTable.Close



David Paulson


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top