471,881 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,881 software developers and data experts.

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 1765

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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.