PDA

View Full Version : Return query from access to excel combobox



CuriousGeorg
03-25-2015, 04:42 AM
Good morning I believe I have set up a query in an excel userform that depending on what is written in Combobox1, will run this query in Access.

However, what I dont understand, is how i return the results of this query into combobox2.

code i have so far is:



Option Explicit


Sub TESTADO()


Dim sDBPath As String, sConnection As String
Dim oconn As ADODB.Connection
Dim objRS As ADODB.Recordset
sDBPath = "S:feedbacktool.accdb"
sConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & sDBPath
Set oconn = New ADODB.Connection
oconn.Open sConnection
Dim strSQL As String
strSQL = "SQLCODE ADDED HERE;"
Dim objcommand As ADODB.Command
Set objcommand = New ADODB.Command
With objcommand


.CommandType = adCmdText
.CommandText = strSQL
.Prepared = True




End With


End Sub

Ive been advised in the past this is to do with Parameters etc but I dont understand this part or how to get results into the next list.

any help on this part would be appreciated.

thanks

Kenneth Hobs
03-25-2015, 09:14 AM
See if this helps. http://www.vbaexpress.com/forum/showthread.php?p=167033