Hey guys
I have some problem. i am using vba in excel to get some data from ms access 2003. I Have a stored query in the access database that i need to run and get the recordset using ADO.
The query that i need to execute is a select query that uses other smaller queries to generate the final dataset. I am trying to execute the query with the following code below:
Dim cnt As ADODB.Connection
Dim rst1 As ADODB.Recordset, rst2 As ADODB.Recordset
Dim stDB As String, stSQL1 As String
stDB = "C:\TTReports.mdb"
stConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & stDB & ";"
Set cnt = New ADODB.Connection
cnt.Open stConn
Set rst1 = cnt.Execute("UTIFrench")
the name of the query is 'UTIFrench' and like i said is a query that uses other queries(not tables) to generate the dataset. When i use the above code i get a enpty recordset i.e. EOF but it though picks up the columns (when i do msgbox rst1.feilds.count it returns 10..which is correct)
But the query when run in access gives me the correct dataset (26 rows and 10 columns)
Please help me out. I would coudl just use the open recordset but the query is soo complicated and so writing the query with subqueries would be a pain in the ass.
Thanks alot....
I have some problem. i am using vba in excel to get some data from ms access 2003. I Have a stored query in the access database that i need to run and get the recordset using ADO.
The query that i need to execute is a select query that uses other smaller queries to generate the final dataset. I am trying to execute the query with the following code below:
Dim cnt As ADODB.Connection
Dim rst1 As ADODB.Recordset, rst2 As ADODB.Recordset
Dim stDB As String, stSQL1 As String
stDB = "C:\TTReports.mdb"
stConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & stDB & ";"
Set cnt = New ADODB.Connection
cnt.Open stConn
Set rst1 = cnt.Execute("UTIFrench")
the name of the query is 'UTIFrench' and like i said is a query that uses other queries(not tables) to generate the dataset. When i use the above code i get a enpty recordset i.e. EOF but it though picks up the columns (when i do msgbox rst1.feilds.count it returns 10..which is correct)
But the query when run in access gives me the correct dataset (26 rows and 10 columns)
Please help me out. I would coudl just use the open recordset but the query is soo complicated and so writing the query with subqueries would be a pain in the ass.
Thanks alot....