Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute SQL Server Pass-Through Query From Access VBA

I have an UPDATE pass through query saved in Access 2007. When I double-click on the pass through query it runs successfully. How can I get this query to run from VBA? I'd like it to run when my "splash screen" loads.

I'm currently using the following code:

CurrentDb.Execute "Q_UPDATE_PASSTHROUGH", dbSQLPassThrough

But I get the following message:

enter image description here

The pass-through query contains all the connection information and I've confirmed the SQL syntax is correct by running it multiple times, so not sure what I'm missing in my VBA call.

like image 895
mntyguy Avatar asked Feb 11 '23 06:02

mntyguy


1 Answers

Use the QueryDef's Execute method:

CurrentDb.QueryDefs("Q_UPDATE_PASSTHROUGH").Execute

I don't think you should need to explicitly include the dbSQLPassThrough option here, but you can try like this if you want it:

CurrentDb.QueryDefs("Q_UPDATE_PASSTHROUGH").Execute dbSQLPassThrough
like image 80
HansUp Avatar answered Feb 13 '23 21:02

HansUp