Hello
I want to share some function in bas file with a project in vb and access.
BackendDb is a MySql Database.
In Access a opened a connection like this:
rec.open sql, CurrentProject.Connection, ...
In VB:
set Conn = new ADODB.Connection
conn.open connStr, usr, pwd
rec.open sql, conn, ...
Now a want to share this code a wrote a function:
Function getConnection() as ADODB.Connection
On Error Resume Next
getConnection = CurrentProject.Connection
if err > 0 the
set getConnection = new ADODB.Connection
getConnection.open connStr, usr, pwd
end if
end function
In VB:
rec.open sql, getConnection(), ...
works fine.
But in Access i think getConnection() is NULL
and I got an Error:
3709: Connetion can't be used, it's closed or unuseable in here.
Who is it possible to write a Function that returns the correct connection
in both projects?
Thanks for help
Nagi