I have a pass-through query in some VB script that works fine and returns the correct data. I have searched the web for some code that could shed some light on how to take these results and insert them into an existing Access table using VB, but no luck. How can I make this work?
Code:
Private Sub RunPassThrough()
Dim qdfPassThrough As DAO.QueryDef, MyDB As Database
Dim strConnect, strSQL As String
strSQL = "BLAH"
If Not IsNull(CurrentDb.QueryDefs("qrySQLPass").SQL) Then 'doesn't exist
CurrentDb.QueryDefs.Delete "qrySQLPass"
End If
Set MyDB = CurrentDb()
Set qdfPassThrough = MyDB.CreateQueryDef("qrySQLPass")
strConnect = "BLAH;"
qdfPassThrough.Connect = "ODBC;" & strConnect
qdfPassThrough.SQL = strSQL
qdfPassThrough.ReturnsRecords = True
qdfPassThrough.Close
Application.RefreshDatabaseWindow
DoCmd.OpenQuery "qrySQLPass", acViewNormal, acReadOnly
DoCmd.Maximize