goddess_spanky
April 13th, 2001, 11:33 AM
I want to create a combo box that will list the items in my FoxPro table. I have created the recordset, connection, etc. but I can't get it to populate in the form.
Also, I want the combo box to store the index value of each option instead of the full name (i.e. 1 instead of "Disconnected Call"). However, I am not sure if it is best to create an auto-index based on the recordset or just pull the primary key value from the table. Either way, how do i accomplish this?
I'm still new to this whole VB thing so any help is appreciated!
Below is what my code looks like:
Sub QuestionLookup()
Dim cnn2 as new ADODB.Connection
Dim rs as new ADODB.Recordset
Dim dbLookup as string
Dim sql_q as string
Dim indexq as Integer
Dim listitem as string
Dim I
sql_q = "SELECT * From tbl_rsd_helpnet"
dbLookup = "DB_Tracking"
cnn2.Open dbLookup
rs.Open sql_q, dbLookup, adOpenStatic, adLockReadOnly
'Create auto-index number for each value in recordset
Do While Not rs.EOF
for I = 1 to 175
listitem = rs!helpnet
'add list items to combo box
cboQuestion.AddItem listitem, I
next I
rs.MoveNext
Loop
End Sub
Also, I want the combo box to store the index value of each option instead of the full name (i.e. 1 instead of "Disconnected Call"). However, I am not sure if it is best to create an auto-index based on the recordset or just pull the primary key value from the table. Either way, how do i accomplish this?
I'm still new to this whole VB thing so any help is appreciated!
Below is what my code looks like:
Sub QuestionLookup()
Dim cnn2 as new ADODB.Connection
Dim rs as new ADODB.Recordset
Dim dbLookup as string
Dim sql_q as string
Dim indexq as Integer
Dim listitem as string
Dim I
sql_q = "SELECT * From tbl_rsd_helpnet"
dbLookup = "DB_Tracking"
cnn2.Open dbLookup
rs.Open sql_q, dbLookup, adOpenStatic, adLockReadOnly
'Create auto-index number for each value in recordset
Do While Not rs.EOF
for I = 1 to 175
listitem = rs!helpnet
'add list items to combo box
cboQuestion.AddItem listitem, I
next I
rs.MoveNext
Loop
End Sub