calling access vba function from asp?

  • Thread starter Alain Bourgeois
  • Start date
A

Alain Bourgeois

Dear all,

I have an asp module connecting to a MS-access database.
I have a vb function MKDate(date, time) in a vba module of this
database.

I would like to query :
SELECT MKDATE(col1, col2) FROM TABLE1

(real query is complex, using unions, etc, but I need one column in
resultset)

But I get an error opening the recordset
"Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Undefined function 'MKDATE' in
expression.
/selfmail/dossier.asp, line 729"

I also tried to copy the code of the function MKDate(date, time) inside
..asp module, no change.


Is it possible to call a vba function inside an asp sql statement?

Regards,
Alain
 
B

Bob Barrows [MVP]

Alain said:
Is it possible to call a vba function inside an asp sql statement?

No, it is impossible to call user-defined VBA procedures from any
external application, including asp. It's been a thorn in our sides for
years. You will need to find another way to accomplish your task.

For this specific purpose, you don't need a user-defined function.
Without knowing the datatypes of col1 and col2, I cannot be specific,
but I'm sure you can do this conversion in your query without a
user-defined function.
 
W

Wes

I don't have ASP setup to try it, but what if you make a Query in Access
which internally calls the vba code & then call that from the ASP?

such as
MyTestQuery =
INSERT INTO TableName(col1, col1, col3) VALUES( @param1, @param2,
MyFunc(@param1,@param1) )

in ASP:

Dim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & Server.MapPath("MyDB.mdb")

' Connection Object
Dim con
Set con = Server.CreateObject("ADODB.Connection")

' connecting to database
con.Open connStr
' executing stored procedure
con.Execute "exec MyTestQuery 'valu1', 'value2', 'value3', 'value4' "

' closing connection and freeing resources
con.Close
Set con = Nothing


Would this work ?
 
B

Bob Barrows [MVP]

Wes said:
I don't have ASP setup to try it, but what if you make a Query in
Access which internally calls the vba code & then call that from the
ASP?
It won't work. BTDT.
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top