两个 MS Access 应用程序之间的通信?

发布于 2025-01-08 08:05:05 字数 363 浏览 3 评论 0原文

我正在寻找一种解决方案来在两个正在运行的 MS Access 应用程序之间进行有效通信。

到目前为止我尝试的方法是使用公共链接表并使用MSMQ服务进行通信。两种方法都有效,但无法将数据或命令从一个应用程序“推送”到另一个应用程序,并且由于 MS Access 不支持 VBA 代码的多线程执行,因此很难在不降低性能的情况下实现轮询。

同时,VBA确实支持addressof运算符(从2000版本开始),这意味着理论上我们也可以在VBA和MS Access中实现回调函数。但我从未见过任何如何将其用于进程间通信的示例,并且希望有任何简单的示例如何将字符串从一个 MS Access 应用程序发送到另一个 MS Access 应用程序,而无需始终监视共享表。

I am looking for a solution to effectively communicate between two running MS Access applications.

The approaches I tried so far is to use a common linked table and to use MSMQ service for communication. Both approaches work, but there is no way to "push" the data or command from one application to another and since MS Access doesn't support multi-threaded execution of VBA code, it is very difficult to implement polling without performance disadvantages.

Same time, VBA does support the addressof operator (from version 2000) that means we can also theoretically implement call-back functions in VBA and MS Access. But I have never seen any example how this can be used for inter-process communication and would appreciate any minimal example how I can send a string from one MS Access application to another without monitoring a shared table all the time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

呢古 2025-01-15 08:05:05

您可以使用 GetObject() 从另一个正在运行的数据库返回 Access.Application 对象。通过应用程序对象,您几乎可以访问您可能需要的所有内容。下面是一个打开表单的人为示例(但您可以使用 Application 对象执行许多其他操作):

Sub TestInterop()
Const mdbPath As String = "C:\OtherApp.mdb"
Dim OtherApp As Access.Application

    Set OtherApp = GetObject(mdbPath)
    OtherApp.Visible = True
    OtherApp.DoCmd.OpenForm "Accounts"
End Sub

如果程序尚未运行,则 GetObject()调用将启动应用程序(如果安装了多个版本的 Access,则需要小心,因为很难在运行时知道哪个版本将实际打开 .mdb)。但是,如果 GetObject() 需要启动应用程序,它将在可见性设置为 False 的情况下启动应用程序,因此我们明确将其设置为 True。如果应用程序已在运行,则将其 Visibility 设置为 True 将不起作用。

You can use GetObject() to return the Access.Application object from another running db. With the application object you have access to just about everything you might need. Here's a contrived example of opening a form (but you can do a myriad of other things with the Application object):

Sub TestInterop()
Const mdbPath As String = "C:\OtherApp.mdb"
Dim OtherApp As Access.Application

    Set OtherApp = GetObject(mdbPath)
    OtherApp.Visible = True
    OtherApp.DoCmd.OpenForm "Accounts"
End Sub

If the program is not already running, the GetObject() call will start the application (you would need to be careful if you have multiple versions of Access installed as it's difficult to know at runtime which version would actually open the .mdb). However, if GetObject() needs to start the app, it will do so with the visibility set to False, so we explicitly set it to True. If the app is already running, setting its Visibility to True will have no effect.

不回头走下去 2025-01-15 08:05:05

认为这是一个疯狂的想法,但可以将所有表放入 sql express 和/或 sql ce 中,并使看起来像这些表的前端?

Consider it a wild idea, but may be put all your tables into sql express and/or sql ce and make look like a frontend to those tables?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文