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!

Populating Combobox with fields returned from ado recordset. 1

Status
Not open for further replies.
Joined
Jan 8, 2001
Messages
163
Location
US
Hi there. I'm trying to figure out how to populate my combo box with one of the fields returned from the ado data object that is created at runtime. The name of my combo box is cboPubrName. I'm including my code below. I would appreciate any help I can get with this. I tried just setting the datasource and datafield fields in the properties window of the combo object but it doesn't populate at run time. I'm somewhat new to VB when it comes to data access.


Dim adoConn As New ADODB.Connection
Dim adoRecordset As New ADODB.Recordset

Private Sub Form_Load()
With adoConn
.ConnectionString = "Provider=MSDAORA.1;Data Source=DATABEAST; Server=DATABEAST;User ID=-----;Password=-----;Persist Security Info=False"
.CursorLocation = adUseClient
.Open
End With

With adoRecordset
.ActiveConnection = adoConn
.CursorType = adOpenDynamic
.Open "Select a.descriptor, a.id from d2main.m_publisher a where exists (select 'X' from d2alllogs.r_pubr_rpt_log b where a.id=b.m_pubr_id)"
End With

cboPubrName.DataSource = adoConn
cboPubrName.DataField = a.descriptor
cboPubrName.AddItem = "ALL PUBLISHERS"

End Sub

Thanks in advance for the help.

CrystalVisualBOracle *:->*
 
Dim adoConn As New ADODB.Connection
Dim adoRecordset As New ADODB.Recordset

Private Sub Form_Load()
With adoConn
.ConnectionString = "Provider=MSDAORA.1;Data Source=DATABEAST; Server=DATABEAST;User ID=-----;Password=-----;Persist Security Info=False"
.CursorLocation = adUseClient
.Open
End With

With adoRecordset
.ActiveConnection = adoConn
.CursorType = adOpenDynamic
.Open "Select a.descriptor, a.id from d2main.m_publisher a where exists (select 'X' from d2alllogs.r_pubr_rpt_log b where a.id=b.m_pubr_id)"
.Movefirst
End With

cboPubrName.Clear

Do Until adoRecordset.EOF
cboPubrName.Additem adoRecordset(0).Value
'Where (0) is the index of the field you want ton use to populate the combobox
adoRecordset.MoveNext
Loop


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top