两个 MS Access 应用程序之间的通信?
我正在寻找一种解决方案来在两个正在运行的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
GetObject()
从另一个正在运行的数据库返回Access.Application
对象。通过应用程序对象,您几乎可以访问您可能需要的所有内容。下面是一个打开表单的人为示例(但您可以使用Application
对象执行许多其他操作):如果程序尚未运行,则
GetObject()
调用将启动应用程序(如果安装了多个版本的 Access,则需要小心,因为很难在运行时知道哪个版本将实际打开 .mdb)。但是,如果GetObject()
需要启动应用程序,它将在可见性设置为 False 的情况下启动应用程序,因此我们明确将其设置为 True。如果应用程序已在运行,则将其 Visibility 设置为 True 将不起作用。You can use
GetObject()
to return theAccess.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 theApplication
object):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, ifGetObject()
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.认为这是一个疯狂的想法,但可以将所有表放入 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?