Hello - I have a working model to grab data into Access using DAO.recordset from a database hosted on SQL server. Connection string works great. I even have a generic function to grab the recordset as long as I pass the sql statement to the function (see below please). How do I do the same thing (not ADO) in Excel? Thanks!
Code:
Function fnServerRecordset(pSQL As String) As DAO.Recordset
Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.CreateQueryDef("")
qdf.Connect = gsConnectionString ' = global connection string that works well
qdf.ReturnsRecords = True
qdf.sql = pSQL
Set fnServerRecordset = qdf.OpenRecordset
qdf.Close
Set qdf = Nothing
End Function