The code I posted will work:
currentdb.QueryDefs("NameOfAboveQueryYouSavedItAs").Execute
It takes ONE LINE.
What you have to do is build the pass-though query. when you build that
query, you type in the sql text as:
exec Restore_DB
You have of course set this query as pass-though,a nd when you do that, you
get chance to enter your connection string...
You can paste in your connection string that works here. We only have to
write ONE LINE of code here.
That one line is:
currentdb.QueryDefs("NameOfAboveQueryYouSavedItAs").Execute
The steps are:
create new query, you choose design view
You get a prompt for the tables, just hit close as we are not going to add a
table to the sql query.
Now, you have a blank query grid (query designer). You go query->sql
specific->pass though
At this point you can type in your command, eg:
exec Restore_DB
Now, make sure you display the property sheet for this query.
from the menu, you go view->Properties (note that if the property sheet is
already displayed, then this will hide the property sheet).
In the property sheet, you see the ODBC Connect Str..you can click on this
box and paste in your existing string, or simply hit the [...] button that
displays, and you can launch a wizard that will allow you to build/setup the
connection string. Or, if you want, simply paste in your connection string
that you had in your past post...
Make sure you set the option "Returns records" to yes, or no depending onif
your stored proc returns data or not.....
Now, save this query.
Then, execute, we use that one line of code to run that pass-though query
currentdb.QueryDefs("NameOfAboveQueryYouSavedItAs").Execute
Of course you can try running the query by clicking on it to see if it
works....
Please try to provide each and every line of code
There is ONLY ONE LINE of code here...again...ONE LINE..it is:
currentdb.QueryDefs("NameOfAboveQueryYouSavedItAs").Execute