By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,654 Members | 1,840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,654 IT Pros & Developers. It's quick & easy.

Execute Access 2002 Macro using ASP

P: 1
I would like to execute a Access 2002 Macro (TransferText) using ASP. Any ideas?

This is what I have so far..

Page 1 *****accessmacro.asp************

<html><body>
<%

strDbName = 'Put the path to your database here
Set objAccess = Server.CreateObject("Access.Application")
objAccess.Visible = False
objAccess.OpenCurrentDatabase Server.MapPath(strDbName)
Set objDB = objAccess.CurrentDb()
macroCount = objDB.containers("Scripts").Documents.Count
%>
<form name="MacroForm" action="accessmacro2.asp" method="post">
<select name="macro">
<%
If macroCount > 0 Then
For Each macro in objDB.Containers("Scripts").Documents
Response.Write("<option value='" & macro.Name & _
"'>" & macro.Name & "</option>" & vbCrLf)
Next

End if
%>
</select>
<input type=submit text="Submit">
</form>


<%
set objDB = nothing
objAccess.Quit acQuitSaveNone
Set objAccess = Nothing
%>
</body></html>


Page 2 *****acessmacro2.asp************

<%
DbPath = 'Put the path to your database here
Set objAccess = Server.CreateObject("Access.Application")
objAccess.Visible = False
objAccess.OpenCurrentDatabase Server.MapPath(DbPath)
Set objDB = objAccess.CurrentDb()

macroName = Request.Form("macro")

objAccess.DoCmd.RunMacro macroName


set objDB = nothing
objAccess.Quit acQuitSaveNone
Set objAccess = Nothing

Response.Write "Your macro has been run!"
%>
Mar 6 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.