Execute Access Module Functions using ASP

M

mb_howard

I am attempting to build a web page using ASP/VBScript that would be able to
call functions within a Module that exists in an Access 2002 "mdb" file.

The ASP code that I have so far is:

<%
On Error Resume Next
Dim access
Set access = Server.CreateObject("Access.Application")
access.opencurrentdatabase "C:\Inetpub\wwwroot\BizRulesProject\bizrules.mdb"

access.DoCmd.openmodule("BizRuleCode")

If Err.Number <> 0 Then
Response.Write "<P><B>The following Error has occured:</B></P>"
Response.Write "Number: " & Err.Number & "<BR>"
Response.Write "Description: " & Err.Description & "<BR>"
Response.Write "Source: " & Err.Source & "<BR>"
Err.Clear
End If
%>

When I try to view this code through a browser, I get the following error:

Number: -2147417851

If I change the line containing "DoCmd.OpenModule" to "DoCmd.RunMacro" I get
the following error:

Microsoft Access can't find the macro 'BizRuleCode.'

I haven't been able to figure out what error (-2147417851) means. I want to
be able to run a function within the module named "BizRuleCode", pass some
parameters to the function, and receive the values returned by the function.
I am not sure how to make the appropriate object calls (using DAO or ADO) to
invoke the module and call the functions inside the module.

Any advice (with code examples) would be greatly appreciated. My email
address is (e-mail address removed).

HELP! :)

Matt
 
M

MacDermott

OpenModule opens the module in design view -
not something you'd want to be doing from the web.

RunMacro runs a macro -
which in Access is rather different from a function.

If the function you want to run in the BizRuleCode module is defined, for
example, like this:
Public MyFunction (A as String, B as Long) As String
you could call it from your ASP code like this:
(afer instantiating your Access object and opening the database)
Dim MyString
MyString=MyFunction("Howard",3214)

HTH
- Turtle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top