在共享模式和独占模式之间切换 Access 数据库?
我正在开发一个需要编辑 Access 数据库中的某些对象的程序。 它还运行一个子程序(说来话长),尝试访问底层 JET 数据库,而 Access 仍通过 ODBC 打开该数据库。
问题是,一旦我开始使用 VBA 编辑 Form 对象(例如,使用 Application.LoadFromText),Access 就会将数据库更改为独占模式。 独占模式本身很好,我知道为什么需要它。 但之后我需要能够切换回“共享”模式,以便我可以运行我的子程序。
我观察到,如果您使用 UI 在设计模式下打开表单,Access 会将数据库切换为独占模式。 (您可以通过尝试从另一台计算机打开它来确认这一点。)但是当您关闭表单设计器时,Access 会立即将其切换回共享模式,这正是我所希望的。
有没有办法使用 VBA / COM 调用来来回切换?
我知道我可以先调用 Application.CloseCurrentDatabase(),然后调用 OpenCurrentDatabase(),但这会关闭所有窗口并扰乱 UI,因此并不理想。
I'm working on a program that needs to edit some objects in an Access database. It also runs a subprogram (long story) that tries to access the underlying JET database while Access still has it open via ODBC.
The problem is that as soon as I start editing Form objects using VBA - for example, using Application.LoadFromText - Access changes the database to exclusive mode. Exclusive mode itself is fine, and I know why it needs it. But I need to be able to switch back to "shared" mode afterwards so that I can run my subprogram.
I've observed that if you use the UI to open a Form in Design mode, Access switches the database to Exclusive. (You can confirm this by trying to open it from another computer.) But when you then close the form designer, Access immediately switches it back to shared mode, which is what I would hope for.
Is there a way to switch it back and forth myself using VBA / COM calls?
I know I can call Application.CloseCurrentDatabase() followed by OpenCurrentDatabase(), but that closes all the windows and upsets the UI, so it's not ideal.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试.UserControl 和.Visible。 我使用它们来转移自动化流程中的控制。
You might try .UserControl and .Visible. I use them to transfer control in automated processes.
将数据库拆分为带有表单/模块/等的单独前端。 和带有表格的后端选项? 这样,如果前端被锁定,后端仍然可以访问。 Access 有一个数据库拆分向导就是用于此目的。
Is splitting the database into a separate front-end with the forms/modules/etc. and back-end with the tables an option? That way if the front-end is locked, the back-end is still accessible. Access has a database splitting wizard for just that.