Sorry I’m a bit dense. (At the moment I am testing against Access and will change to SQL later). I have managed to run the query against SQL2000 and I have populated a recordset. I have used the code below to make sure I am pulling data back from the database. This code copies the recordset into a spreadsheet, but I can’t see how to populate a combo box. Please could you tell me what I am missing? Many Thanks
Sub Import_AccessData(
Dim cnt As ADODB.Connectio
Dim rst1 As ADODB.Recordse
Dim stDB As String, stSQL1 As String, stSQL2 As Strin
Dim stConn As Strin
Dim wbBook As Workboo
Dim wsSheet1 As Workshee
Dim lnField As Long, lnCount As Lon
Set cnt = New ADODB.Connectio
Set rst1 = New ADODB.Recordse
Set rst2 = New ADODB.Recordse
Set wbBook = ThisWorkboo
Set wsSheet1 = wbBook.Worksheets(1
stDB = "c:\ExcelTest.mdb
stConn = "Provider=Microsoft.Jet.OLEDB.4.0;" &
"Data Source=" & stDB & ";
stSQL1 = "SELECT DeptNo FROM NewTable
wsSheet1.Range("A1").CurrentRegion.Clea
With cn
..Open (stConn)
..CursorLocation = adUseClien
End Wit
With rst
..Open stSQL1, cnt
Set .ActiveConnection = Nothing
End Wit
With wsSheet
..Cells(2, 1).CopyFromRecordset rst
End Wit
rst1.Clos
Set rst1 = Nothin
cnt.Clos
Set cnt = Nothin
End Su
----- Bob Phillips wrote: ----
Use ADO to query SQL2000, and populate an array with the recordset, and the
load the combo from that array
As to whether activex or userform, it depends what else you want. If it i
only a combobox, activex should be enough, if you want more controls relate
to the combo, you would probably be better with a userform
--
HT
Bob Phillip
... looking out across Poole Harbour to the Purbeck
(remove nothere from the email address if mailing direct
Mandy said:
Please can someone tell me how to populate a combo box from a SQL quer against SQL2000
I'm using XL2000 and W2K. And should I be using activex or userfor
controls - is there a difference