469,326 Members | 1,588 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

Execute Access 2002 Macro using ASP

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
0 1703

Post your reply

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

Similar topics

15 posts views Thread by Jeff Keller | last post: by
26 posts views Thread by jamesbeswick | last post: by
52 posts views Thread by Neil | last post: by
23 posts views Thread by Reggie | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.