即使在docmd.close之后,表格也将我的表锁紧了 [英] Form has my table locked down tight even after docmd.close

查看:160
本文介绍了即使在docmd.close之后,表格也将我的表锁紧了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起,这是文本专家们的话题,但这需要解释,太多的代码无法发布...

Sorry for the wall of text guys but this one requires expliaining, way too much code to post...

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

I'm importing fixed width files into access in methods that require data entry. I import the file using transferText into two specs (ones global, the other is special circumstance).

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

I have a function that uses DAO to cycle through all Field objects in TableDefs to build a duplicate table including an AutoIncrement PK so I have the ability to edit these records. I push the data into that table with INSERT INTO.

效果很好.发现错误后,用户进入数据输入以手动更正错误,这使您可以筛选出400个字符行,并以应有的方式重组所有内容.很棒!

Works great. Errors are found, user goes into data entry to manually correct them which beats sifting through 400 character lines and reorganizing everything the way its supposed to be. Works great!

问题:更改数据条目后,将按下提交按钮,该调用按钮将调用表单外部模块内的函数.它会关闭数据输入表单,并将信息减去自动递增的PK推回到原始表中,并被要求丢弃具有ID的复制表,并再次生成一个新的错误查找...

The problem: When the data entry changes are made a commit button is pressed which calls a function inside a module outside of the form. It closes the data entry form and pushes the information back to the original table minus the autoincremented PK, and is SUPPOSED to DROP the replicated table with ID's, and generate a new one searching once again for errors...

它可以很好地推回原始位置,但不会丢弃ID表.总是向我返回一条消息,指示该表已被锁定.香港专业教育学院注意到表一直被锁定直到所有功能/子退出.在执行代码的任何时候,我都无法手动删除它,一旦执行完成,我就可以删除它.

It pushes back to the original just fine, but it will not DROP the ID table. Always returns to me with a message indicating this table is locked. Ive noticed the table is indefiniatly locked down until all functions/subs exit. At any time stepping through the code I cannot delete it manually, once the execution has finished I am able to remove it.

我假设由于我是通过窗体中的命令调用此函数的,因此直到所有代码完成并且窗体终止可以被调用并执行其操作后,锁才会被释放.有什么想法吗?是的,这非常野蛮,但是效果很好,我只需要能够从地球上拆下这张桌子,这样我就可以删除更新的副本...

I am assuming that since I called this through a command in the form, that the lock will not be released until all code finishes and the form terminate can be called and do its thing. Any thoughts? Yes this is very barbaric but it works quite well, I just need to be able to rip this other table off the planet so I can redrop an updated copy...

在最坏的情况下,我可以使用户关闭表单并单击主表单中的另一个按钮,但这在设计时会考虑到用户的权限.但是,这现在引起了我的全部关注,并且至少想找到一种解决方案,即使它不是最佳解决方案.

In the worst case I can make the user close the form out and hit another button in the main form but this is being designed heavily with user compitence in mind. However this now has my full attention and would like to at least find a solution even if it's not the optimal one.

-EDIT-

此问题中使用了两种形式

Two forms are used in this problem

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-数据输入表单

FormB - Data Entry Form

打开此表单后,表tempExtractID便被锁定,因此无法删除该表.表单的记录源会针对Problems_t中的ID查询tempExtractID,以仅返回我们需要键入的内容.

As soon as I open this form, the table tempExtractID becomes locked and I cannot drop the table. The recordsource to the form querys tempExtractID against the ID's in Problems_t to return only what we need to key.

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

I cannot drop the table until the form has fully terminated. Button on the Data Entry form is pressed to commit changes, in which there are only 5 lines of code that get to fire off before I get my lock error.

*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"

这是在打开表单(表首先被锁定的位置)之间持续运行直到所有子&的时间之间运行的唯一代码.功能已经完成.

This is the only code that is run between the time where the form is opened (Where the table first gets locked) and continues to be locked until all subs & functions have completed.

推荐答案

我建议将表单的记录源设置为vbNullString,然后删除表.除非您也有组合框等绑定到此表,否则此方法应该起作用.

I suggest setting the recordsource of the form to vbNullString and then deleting the table. This should work, unless you also have comboboxes and so forth bound to this table.

这篇关于即使在docmd.close之后,表格也将我的表锁紧了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆