Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass-through query that does not return records

Status
Not open for further replies.

AMcNabb

Technical User
Dec 22, 2006
1
US
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:pass Through Query Connect String") = "ODBC;DSN=ADB Test Environ;Trusted_Connection=Yes;"
cmd.Execute

Set cat = Nothing
Set cmd = Nothing

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top