Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 21st, 2007, 04:09 PM
Registered User
 
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Execute Stored Procedure from VBA

Hi!

I'm trying to run a SS stored procedure
from the Access front end.
The code in the Switchboard's Form_Load event goes like this:
Code:
Dim qrySQL As DAO.QueryDef
Set qrySQL = CurrentDb().CreateQueryDef("sp_setapprole")
qrySQL.SQL = "EXEC sp_setapprole " & "MY_Role" & ", " & "MY_Role_PW" & ";"
qrySQL.Execute
qrySQL.SQL = "exec sp_setapprole role_name_here, role_pwd_here"
Set qrySQL = Nothing
But it always gives me Run time error 3129:
Invalid SQL statement; expected “DELETE’, ‘INSERT’, ‘PROCEDURE’,
‘SELECT’, or ‘UPDATE’.
 at qrySQL.SQL = "EXEC sp_setapprole " & "MY_Role" & ", " & "MY_Role_PW" & ";"

What can be a problem here? Please help!!!! Thanks!
 
Old February 22nd, 2007, 12:52 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I am not sure if you can run a SQL Server stored procedure from an Access front end, but if you can, you sure cannot do it with DAO. You need to switch to ADO to talk to a SQL Server. DAO is only for Jet databases.

HTH

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored procedure and VBA jesseleon Access VBA 7 September 15th, 2011 12:46 PM
Get Stored Procedure Output using Access VBA LandLocked Access VBA 3 June 20th, 2007 11:20 AM
Running stored procedure in Access VBA Bryon Burbage Access VBA 0 July 21st, 2006 09:14 AM
MS SQL Stored procedure and VBA jesseleon Pro VB Databases 0 July 30th, 2004 01:16 PM
Create Stored Procedure in VBA Mitch Access 0 April 14th, 2004 03:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.