Moh*_*oth 3 ms-access locking create-table drop-table
对不起文本家伙的墙,但这个需要expliaining,太多的代码发布...
我在需要数据输入的方法中将固定宽度文件导入访问.我使用transferText将文件导入两个规范(一个是全局的,另一个是特殊情况).
我有一个函数,它使用DAO循环遍历TableDefs中的所有Field对象,以构建包含AutoIncrement PK的重复表,以便我能够编辑这些记录.我用INSERT INTO将数据推送到该表中.
效果很好.发现错误,用户进入数据输入以手动纠正它们,这些节拍通过筛选400个字符行并按照预期的方式重新组织所有内容.效果很好!
问题:当数据条目发生变化时,会按下一个提交按钮,该按钮调用表单外部模块内的函数.它关闭数据输入表单并将信息推回到原始表减去自动增量PK,并且被支持DROP复制表的ID,并生成一个新的再次搜索错误...
它推回原来很好,但它不会DROP ID表.总是返回给我一条消息,表明该表已被锁定.我注意到表被无限制地锁定,直到所有函数/子退出.在任何时候单步执行代码我都无法手动删除它,一旦执行完成,我就可以删除它.
我假设因为我通过表单中的命令调用它,所以在所有代码完成并且表单终止可以被调用并执行其操作之前不会释放锁.有什么想法吗?是的,这是非常野蛮但它运作良好,我只需要能够撕掉地球上的另一张桌子,这样我就可以重新制作更新的副本......
在最糟糕的情况下,我可以让用户关闭窗体并点击主窗体中的另一个按钮,但这在设计时考虑到了用户的合规性.然而,这现在我全神贯注,并希望至少找到一个解决方案,即使它不是最佳解决方案.
-编辑-
在这个问题中使用了两种形式
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.
Run Code Online (Sandbox Code Playgroud)
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"
Run Code Online (Sandbox Code Playgroud)
这是在打开表单的时间(表首先被锁定的位置)之间运行的唯一代码,并且继续被锁定直到所有子表和函数都已完成.
| 归档时间: |
|
| 查看次数: |
7615 次 |
| 最近记录: |