SQL & mdb

  • Thread starter Thread starter Mirza
  • Start date Start date
M

Mirza

I've tried to execute a stored procedure using

docmd.runSQL "EXECUTE sp_DELremi"

and I'm getting an error msg run-time error 3129
Invalid SQL statement.Does this command work only in .adp
and is there any way to execute the stored procedure from
mdb?

Thanks in advance,

Mirza
 
Hi Mirza, try this (you will need a reference to MS DAO)

Dim db as DAO.Database
Set db = DBEngine.Workspaces(0).Databases(0)

db.Execute "sp_DELremi"

Hope this helps, Graeme
 
It won't work the way you code because EXECUTE is an SQL Server command and
the SP resides on the SQL Server, not in your Access MDB.

You will need to use Pass-Through Query as the wrapper for your EXECUTE
statement which the Connection Property of the Pass-Through Query points to
the SQL Server Database. Alternatively, create a Connection to the SQL
Server Database and use the EXECUTE Method of the Connection.

Check Access Help on Pass-Through Queries and Access VB Help on (ADODB)
Connection Object.
 
Back
Top