I'm using Access as a front end to a SQL Sever database -- via linked tables. I'm generating a pass-thru query to return a recordset. When I run the query for the first time from a form, I get the error -- ODBC error 3151 - connection to *my database* failed.
Now, if I close the form, open it again and re-run the query, everything works fine.
Also, the pass-thru query is created before the error is occuring so I don't understand why the connection failed when it actually connected and returned records.
Does anyone have any clue????
Here is the line that is failing:
Set db = CurrentDb
Set rs = db.OpenRecordset("QueryCandidates" -- this is my pass-thru query and if i view it from the query window, it works fine, just not thru code. also, i have tried using this code
Set db = CurrentDb
Set rs = db.OpenRecordset("QueryCandidates", dbOpenDynaset, dbSeeChanges)
Any help would be greatly appreciated.
Thanks in advance
Now, if I close the form, open it again and re-run the query, everything works fine.
Also, the pass-thru query is created before the error is occuring so I don't understand why the connection failed when it actually connected and returned records.
Does anyone have any clue????
Here is the line that is failing:
Set db = CurrentDb
Set rs = db.OpenRecordset("QueryCandidates" -- this is my pass-thru query and if i view it from the query window, it works fine, just not thru code. also, i have tried using this code
Set db = CurrentDb
Set rs = db.OpenRecordset("QueryCandidates", dbOpenDynaset, dbSeeChanges)
Any help would be greatly appreciated.
Thanks in advance