A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

From another mdb run VBA code



 
 
Thread Tools Display Modes
  #1  
Old January 2nd, 2010, 04:31 PM posted to microsoft.public.access.forms
Trev B
external usenet poster
 
Posts: 8
Default From another mdb run VBA code

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
--
Trev B
  #2  
Old January 2nd, 2010, 06:01 PM posted to microsoft.public.access.forms
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default From another mdb run VBA code

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

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


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

  #3  
Old January 3rd, 2010, 09:13 PM posted to microsoft.public.access.forms
David W. Fenton
external usenet poster
 
Posts: 3,373
Default From another mdb run VBA code

Tom van Stiphout wrote in
:

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")

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:09 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.