vba Microsoft Access 无法保存设计更改,因为另一个用户打开了该文件...但我是唯一的用户?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7109000/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 13:50:36  来源:igfitidea点击:

Microsoft Access can't save design changes because another user has the file open... but I am the only user?

vbams-access-2010

提问by p0lar_bear

Just a little background: I am using Access 2010 to create forms and VBA code in an Access 2003 format database. For some reason, Access 2007 format databases always corrupt on me when I make changes and save them with a particular group of objects, but that's for another discussion.

只是一点背景知识:我正在使用 Access 2010 在 Access 2003 格式数据库中创建表单和 VBA 代码。出于某种原因,当我进行更改并将它们与特定对象组一起保存时,Access 2007 格式数据库总是对我造成损坏,但这是另一个讨论。

When writing VBA code in this Access 2003 database, any time my code breaks (via breakpoint or an unhandled error) and I make a correction, Access tells me that it can't save back to the database because another user has it open. However, I am the only user working on the database; this is a local copy of the database and it's sitting on my desktop.

在此 Access 2003 数据库中编写 VBA 代码时,只要我的代码中断(通过断点或未处理的错误)并进行更正,Access 就会告诉我它无法保存回数据库,因为另一个用户已打开它。但是,我是唯一在数据库上工作的用户;这是数据库的本地副本,它位于我的桌面上。

The LDB file can't be deleted because Access is using it. When I first load the database, I see my machine name and "Admin" when opening the LDB in a text or hex editor. After a break, I see that plus a duplicate entry, but this time around "admin" has a lower-case "A."

无法删除 LDB 文件,因为 Access 正在使用它。当我第一次加载数据库时,在文本或十六进制编辑器中打开 LDB 时,我会看到我的机器名称和“管理员”。休息后,我看到加上一个重复的条目,但这次“admin”有一个小写的“A”。

Closing the database and reopening it fixes the problem but makes it needlessly cumbersome to debug my code. Anyone else encounter this issue and/or have a fix for it?

关闭数据库并重新打开它可以解决问题,但会使调试我的代码变得不必要地麻烦。还有其他人遇到过这个问题和/或有解决方法吗?

采纳答案by transistor1

It might be helpful to know what your code is doing when this happens. Certainly that's not normal behavior. For instance, are you opening another database with New Access.Application? Are you using ADO or DAO to access records in the database with a connection string?

了解您的代码在发生这种情况时在做什么可能会有所帮助。当然,这不是正常的行为。例如,您是否使用New Access.Application?打开另一个数据库?您是使用 ADO 还是 DAO 通过连接字符串访问数据库中的记录?

There are no external connections to the database at all.

根本没有与数据库的外部连接。

It may not matter if there are externalconnections to the database if you are using a connection string to connect to the open database; not sure but that may be seen as an external connection... you may want to use CurrentDBfor DAO, or CurrentProject.Connectionas your ActiveConnection for any ADO queries.

如果您使用连接字符串连接到打开的数据库,则是否有到数据库的外部连接可能无关紧要;不确定,但可能会被视为外部连接...您可能希望CurrentDB用于 DAO,或CurrentProject.Connection用作任何 ADO 查询的 ActiveConnection。

I am assuming that this problem persists through reboots; but for the sake of argument, try closing out Access and going to the task manager to make sure you have no other instances of MSAccess.exe running. You might even try closing all Office products and/or making sure that Access is the only Office product running. I have seen some weird conflicts between Microsoft Communicator and Outlook; so it's not entirely out of the question for Access to have issues with another MS product.

我假设这个问题在重启后仍然存在;但为了论证起见,请尝试关闭 Access 并转到任务管理器,以确保没有其他 MSAccess.exe 实例正在运行。您甚至可以尝试关闭所有 Office 产品和/或确保 Access 是唯一运行的 Office 产品。我看到 Microsoft Communicator 和 Outlook 之间有一些奇怪的冲突;因此,Access 与其他 MS 产品存在问题并非完全不可能。

You may also want to check the size of the database to make sure it's not exceeded 2GB. That causes the infamous "Invalid parameter" error; perhaps it might be causing this as well.

您可能还想检查数据库的大小以确保它没有超过 2GB。这会导致臭名昭著的“无效参数”错误;也许它也可能导致这种情况。

With no other details about how your program works, we may only be able to offer generic advice like this.

由于没有关于您的程序如何工作的其他详细信息,我们可能只能提供这样的一般建议。

回答by Bob Brooks

I have discovered a way to cause the problem discussed above (and thereby to correct it). Turns out if you create a database object and set it to the current database, you get this problem. That is,

我发现了一种导致上面讨论的问题的方法(从而纠正它)。事实证明,如果您创建一个数据库对象并将其设置为当前数据库,则会出现此问题。那是,

dim cdb as database

将 cdb 调暗为数据库

set cdb = currentdb

设置 cdb = currentdb

From this point on, you're cooked. Instead, figure a way around this by possibly using currentdb directly or not using it at all. This worked for me.

从这一点开始,你就熟了。相反,通过可能直接使用 currentdb 或根本不使用它来解决这个问题。这对我有用。

回答by Saravanan Ashok

The solution:

解决方案:

options > current database > click enable -track name auto correct info

回答by DipakRiswadkar

In your VBA Try checking that all your open Connections to the database are closed. Until the connection is open the LDB fill will be there.

在您的 VBA 中尝试检查所有打开的数据库连接是否已关闭。在连接打开之前,LDB 填充将在那里。