gpt4 book ai didi

ms-access - 即使在 docmd.close 之后,表格也将我的 table 锁定得很紧

转载 作者:行者123 更新时间:2023-12-01 08:41:44 25 4
gpt4 key购买 nike

对不起,文字墙的人,但这个需要解释,太多的代码要发布......

我正在将固定宽度的文件导入到需要数据输入的方法中。我使用 transferText 将文件导入到两个规范中(一个是全局的,另一个是特殊情况)。

我有一个函数,它使用 DAO 循环遍历 TableDefs 中的所有 Field 对象,以构建一个包含 AutoIncrement PK 的重复表,因此我能够编辑这些记录。我使用 INSERT INTO 将数据推送到该表中。

效果很好。发现错误后,用户进入数据输入以手动更正错误,这比筛选 400 个字符行并按照应有的方式重新组织所有内容要好。效果很好!

问题:当数据输入发生更改时,按下提交按钮,该按钮调用表单外模块内的函数。它关闭数据输入表单并将信息推送回原始表减去自动递增的 PK,并且应该删除带有 ID 的复制表,并生成一个新的表,再次搜索错误...

它可以很好地推回到原来的状态,但它不会删除 ID 表。总是返回给我一条消息,表明此表已锁定。我注意到该表被无限锁定,直到所有函数/子退出。在任何时候单步执行代码时,我都无法手动删除它,一旦执行完成,我就可以将其删除。

我假设由于我通过表单中的命令调用它,因此在所有代码完成并且可以调用表单终止并执行其操作之前,不会释放锁。有什么想法吗?是的,这很野蛮,但效果很好,我只需要能够将这张 table 从地球上撕下来,这样我就可以重新删除更新的副本......

在最坏的情况下,我可以让用户关闭表单并点击主表单中的另一个按钮,但这是在考虑用户竞争力的情况下设计的。然而,这现在引起了我的全部关注,并且希望至少找到一个解决方案,即使它不是最佳解决方案。

-编辑-

本题使用了两种形式

FormA (Role: Load in and search for problems)

Examine button is pressed that:

- Uses TextTransfer based on predefined specs into tempExtract to
import the file

- DAO fires off on the Fields collection in tableDefs for
tempExtract, creates new table tempExtractID

- Performs searches through the file to find errors. Errors are saved to
a table Problem_t. Table contains Problem_ID (Set from the ID field
added to tempExtractID) and Description

- Execution of these tasks is successfully requerying the initial
form to showing a list of problems and number of occurances. A button
gains visibility, with onClick that opens the form DataEntry.

- At this point in the code after DAO execution, I can DROP the table
tempExtractID. DAO is NOT used again and was only used to build a new table.

FormB - 数据输入表

打开此表单后,表 tempExtractID 立即被锁定,我无法删除该表。表单的记录源根据 Problems_t 中的 ID 查询 tempExtractID,以仅返回我们需要键入的内容。

在表单完全终止之前,我无法删除表格。按下数据输入表单上的按钮以提交更改,其中只有 5 行代码会在我收到锁定错误之前触发。

*Xargs refers to the list of Field names pulled earlier through DAO.  As DAO loops through Field objects, the physical names are added to an Xargs String which is placed in this table.  Basically everything but the AutoNumber is being inserted back

docmd.Close acForm, "frmDataEntry", acSaveNo
call reInitializeExtract
> docmd.RunSQL "DELETE FROM tempExtract"
> docmd.RunSQL "INSERT INTO tempExtract SELECT (" & DLookup("Value", "CONFIG_t", "Item = 'Xargs'" & ") FROM tempExtractID"
docmd.DeleteObject acTable, "tempExtractID"

这是在打开表单(表第一次被锁定的地方)和继续锁定直到所有子和函数完成之间运行的唯一代码。

最佳答案

我建议将表单的记录源设置为vbNullString,然后删除表。这应该可以工作,除非您还有组合框等绑定(bind)到此表。

关于ms-access - 即使在 docmd.close 之后,表格也将我的 table 锁定得很紧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1647591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com