Apr 2, 2002 #1 jschwick Programmer Apr 2, 2002 2 AU I'm looking to link a combobox with a database so that i can display all entries from a particular field of the database. How can i do this???
I'm looking to link a combobox with a database so that i can display all entries from a particular field of the database. How can i do this???
Apr 5, 2002 #2 Malchik Programmer Dec 8, 2001 148 CA Hi, You need a connection between VB and the DB, a Recorset, a query, a combobox and a loop. Ex: 'Assuming the connection is open Dim RS As New ADODB.Recordset Dim sSQL AS String 'Don't sort the query, you can do it in the combobox, 'it will be faster sSQL = "SELECT Client_ID, Client_Name FROM Client" RS.Open sSQL, adoConnection While Not RS.EOF cboClient.AddItem RS.Fields(1) cboClient.ItemData(cboClient.NewIndex)=RS.Fields(0) RS.MoveNext Wend RS.Close Set RS = Nothing that should do it!!! Mal'chik Upvote 0 Downvote
Hi, You need a connection between VB and the DB, a Recorset, a query, a combobox and a loop. Ex: 'Assuming the connection is open Dim RS As New ADODB.Recordset Dim sSQL AS String 'Don't sort the query, you can do it in the combobox, 'it will be faster sSQL = "SELECT Client_ID, Client_Name FROM Client" RS.Open sSQL, adoConnection While Not RS.EOF cboClient.AddItem RS.Fields(1) cboClient.ItemData(cboClient.NewIndex)=RS.Fields(0) RS.MoveNext Wend RS.Close Set RS = Nothing that should do it!!! Mal'chik