Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 21st, 2007, 04:09 PM
Registered User
Join Date: Feb 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Execute Stored Procedure from VBA


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:
Dim qrySQL As DAO.QueryDef
Set qrySQL = CurrentDb().CreateQueryDef("sp_setapprole")
qrySQL.SQL = "EXEC sp_setapprole " & "MY_Role" & ", " & "MY_Role_PW" & ";"
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’,
 at qrySQL.SQL = "EXEC sp_setapprole " & "MY_Role" & ", " & "MY_Role_PW" & ";"

What can be a problem here? Please help!!!! Thanks!
Reply With Quote
  #2 (permalink)  
Old February 22nd, 2007, 12:52 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

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.


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 08:20 AM.

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