From another mdb run VBA code

  • Thread starter Thread starter Trev B
  • Start date Start date
T

Trev B

I have a function updateTables() in a a different db.

How do I run this remotely. In addition is it possible to pass parmeters

Regards
 
On Sat, 2 Jan 2010 08:31:01 -0800, Trev B

Yes you can. Here is an example:
In database 1:
Sub test()
Dim objAccess As New Access.Application
objAccess.OpenCurrentDatabase "c:\test\database2.accdb"
objAccess.Eval "Hello('aaa')"
End Sub

In database 2 in a standard module:
Public Function Hello(ByVal s As String)
MsgBox "Hello " & s
End Function

-Tom.
Microsoft Access MVP
 
Yes you can. Here is an example:
In database 1:
Sub test()
Dim objAccess As New Access.Application
objAccess.OpenCurrentDatabase "c:\test\database2.accdb"
objAccess.Eval "Hello('aaa')"
End Sub

In database 2 in a standard module:
Public Function Hello(ByVal s As String)
MsgBox "Hello " & s
End Function

Another option would be to use Application.Run:

Application.Run("c:\test\database2.Hello", "aaa")
 
Back
Top