LACCDB记录锁定文件未关闭

发布于 2025-01-15 23:03:23 字数 1518 浏览 2 评论 0原文

我的后端数据文件保持打开状态时出现问题,LACCDB 文件保持打开状态。我已将其范围缩小到导致问题的几行代码。我尝试了多种解决方案,但没有一个对我有用。唯一的选择是关闭前端,但这并不实用。

我想复制此 BE 文件,但如果 LACCDB 文件打开则无法复制。没有其他用户。我尝试删除查询和表(链接),但这仍然无法解决问题。运行 MS Access 2007 并在各种 PC 上进行了尝试。我还尝试将 ACCDB 文件从映射驱动器移动到本地驱动器。

代码:

Function TestMyLinks()
MyQuery="Test-Filter"
MyTable="Test"
MyCriteria = "[TestId]> 1"
MyCriteria = "SELECT [" & MyTable & "].*" & " FROM [" & MyTable & "] Where " & MyCriteria

DoCmd.DeleteObject acQuery, MyQuery    'Delete new query.
Set qdf = DataDb.CreateQueryDef(MyQuery, MyCriteria) ' Create new query
DoCmd.Close acQuery, MyQuery, acSaveYesDoCmd.Close acTable, "Test", acSaveYes

' This following code does not make any difference
'DoCmd.DeleteObject acQuery, "Test-Filter"
'DoCmd.DeleteObject acTable, "Test"
'DoCmd.TransferDatabase TransferType:=acLink, _
'        DatabaseType:="Microsoft Access", _
'        DatabaseName:="C:\MyClock\Test.accdb", _
'        ObjectType:=acTable, _
'        Source:="Attendance", _
'        Destination:="Attendance"
'Application.SetOption "Auto compact", True
'DoCmd.RunCommand acCmdCompactDatabase
'DBEngine.CompactDatabase "C:\MyClock\Test.accdb", "C:\MyClock\TestA.accdb" ' This fails1 as file locked
End Function

我尝试使用代码关闭表:

DoCmd.Close acQuery, "Test-Filter", acSaveNo
DoCmd.Close acTable, "Test", acSaveNo

我还尝试按照另一篇文章释放内存:

'release memory
qdf.Close 'i changed qdef to qdf here and below
Set qdf = Nothing

I have a problem with my back end data file staying open, LACCDB file stays open. I have narrowed it down to a few lines of code that is causing the problem. I have tried a number of solutions but nothing works for me. The only option is to close the front end but that's not practical.

I want to copy this BE file but cant if the LACCDB file is open. No other users. I have tried deleting both the Query and the table(linked) but that still does not resolve the issue. Running MS Access 2007 and tried on various PC's. I have also tried moving the ACCDB file from Mapped drive to local drive.

The code:

Function TestMyLinks()
MyQuery="Test-Filter"
MyTable="Test"
MyCriteria = "[TestId]> 1"
MyCriteria = "SELECT [" & MyTable & "].*" & " FROM [" & MyTable & "] Where " & MyCriteria

DoCmd.DeleteObject acQuery, MyQuery    'Delete new query.
Set qdf = DataDb.CreateQueryDef(MyQuery, MyCriteria) ' Create new query
DoCmd.Close acQuery, MyQuery, acSaveYesDoCmd.Close acTable, "Test", acSaveYes

' This following code does not make any difference
'DoCmd.DeleteObject acQuery, "Test-Filter"
'DoCmd.DeleteObject acTable, "Test"
'DoCmd.TransferDatabase TransferType:=acLink, _
'        DatabaseType:="Microsoft Access", _
'        DatabaseName:="C:\MyClock\Test.accdb", _
'        ObjectType:=acTable, _
'        Source:="Attendance", _
'        Destination:="Attendance"
'Application.SetOption "Auto compact", True
'DoCmd.RunCommand acCmdCompactDatabase
'DBEngine.CompactDatabase "C:\MyClock\Test.accdb", "C:\MyClock\TestA.accdb" ' This fails1 as file locked
End Function

I have tried closing the tables using code:

DoCmd.Close acQuery, "Test-Filter", acSaveNo
DoCmd.Close acTable, "Test", acSaveNo

I have also tried as per another post to release memory:

'release memory
qdf.Close 'i changed qdef to qdf here and below
Set qdf = Nothing

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文