I've set up some pass through queries that create tables on the SQLServer. I am able to execute these queries directly, but when I try to execute them using VBA I get an "ODBC call failed" error. I think the problem lies in the fact that these queries do not return any records, but I don't know how to allow for that using VBA.
Here is my code:
Sub ExecPassThru()
Dim cat As ADOX.Catalog
Dim cmd As ADODB.Command
Set cat = New ADOX.Catalog
Set cmd = New ADODB.Command
cat.ActiveConnection = CurrentProject.Connection
Set cmd.ActiveConnection = cat.ActiveConnection
cmd.CommandText = "HealthSummary"
cmd.Properties("Jet OLEDB:ODBC Pass-Through Statement") = True
cmd.Properties("Jet OLEDB
ass Through Query Connect String") = "ODBC;DSN=ADB Test Environ;Trusted_Connection=Yes;"
cmd.Execute
Set cat = Nothing
Set cmd = Nothing
End Sub
Here is my code:
Sub ExecPassThru()
Dim cat As ADOX.Catalog
Dim cmd As ADODB.Command
Set cat = New ADOX.Catalog
Set cmd = New ADODB.Command
cat.ActiveConnection = CurrentProject.Connection
Set cmd.ActiveConnection = cat.ActiveConnection
cmd.CommandText = "HealthSummary"
cmd.Properties("Jet OLEDB:ODBC Pass-Through Statement") = True
cmd.Properties("Jet OLEDB
cmd.Execute
Set cat = Nothing
Set cmd = Nothing
End Sub