How can I run a stored procedure on SQL Server from an Access form? Whenever I execute the below code it errors with "Invalid SQL Statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'"
Note: the stored procedure exists in the database and executes fine from SQL Query Analyzer.
Thanks in advance.
Code:
Private Sub Command27_Click()
On Error GoTo Err_Command27_Click
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSql As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
strSql = "exec mail_count TEST_TABLE"
qdf.SQL = strSql
Set db = Nothing
Set qdf = Nothing
Exit_Command27_Click:
Exit Sub
Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click
End Sub
Note: the stored procedure exists in the database and executes fine from SQL Query Analyzer.
Thanks in advance.