Link to home
Start Free TrialLog in
Avatar of joygomez
joygomezFlag for United States of America

asked on

ODBC connection fails in MS Access Pass through query

In MS Access... in Pass through query... when executing, I am getting this error 'ODBC - connection to STW failed'.

This is what I have in the Pass through query.
exec CaculateVariableFixedTimes '41428' , '2018-01-01' , '2'

The stored procedure works perfectly when I run it in SQL.  This used to work properly when I had my SQL on my local machine.  Now I am connecting to a server.   I am guessing that is the issue.  I am able to connect to my tables and queries properly.
ASKER CERTIFIED SOLUTION
Avatar of Kelvin Sparks
Kelvin Sparks
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joygomez

ASKER

this is my connection string:    
strConnect = "ODBC;Driver={SQL Server};Server=" & rsTables!ServerName & ";Database=" & rsTables!DatabaseName & ";Trusted_Connection=True"


I am calling this from a event and this is what i have as below... Where below should i place the connection string?

Private Sub Form_Close()
 
Dim qdf As QueryDef
Set qdf = CurrentDb.QueryDefs("PassThruQuery_Main")
qdf.SQL = "exec CaculateVariableFixedTimes" & " " & "'" & Me.Text53 & "'" & " " & "," & " " & "'" & Me.Text50 & "'" & " " & "," & " " & "'" & Me.Text54 & "'"
qdf.Execute
Thank you... i have resolved it...