对话表单的记录已被锁定

huangapple go评论68阅读模式
英文:

dialog form 's record is locked

问题

有一个名为 Arzyabi_Tamin_Konande_da 的表单,通过以下代码以对话框形式打开:

Me.Form.Dirty = False
Dim ASK As Integer
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
With rs
    .MoveFirst
    Do While Not rs.EOF
        .Edit
        If (!Tahvil_Tmp = True) * (!Az_Tankhah = False) Then
            If DLookup("[Saff_Arzyabi_2]", "Arzyabi_Tamin_Konande_sh", _
                "val([Cod_Tamin_Konande]) = '" & !Cod_Tamin_Konande & "'") = True Then
                DoCmd.OpenForm "Arzyabi_Tamin_Konande_da", acNormal, , "[Cod_Tamin_Konande]=" & !Cod_Tamin_Konande, , acdialog
            End If
        .Update
        .MoveNext
    Loop
End With

但当表单打开时,我无法更改记录,所有记录都被锁定。另外,如果我以 acWindowNormal 模式打开表单,一切都正常。

对话表单的记录已被锁定

我尝试为循环创建另一个查询,但它没有起作用。

英文:

I have form (Arzyabi_Tamin_Konande_da) that opens in dialog form by this code:

<pre><code>
Me.Form.Dirty = False
Dim ASK As Integer
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
With rs
.MoveFirst
Do While Not rs.EOF
.Edit
If (!Tahvil_Tmp = True) * (!Az_Tankhah = False) Then
If DLookup("[Saff_Arzyabi_2]", "Arzyabi_Tamin_Konande_sh", _
"val([Cod_Tamin_Konande]) = '" & !Cod_Tamin_Konande & "'") = True Then
DoCmd.OpenForm "Arzyabi_Tamin_Konande_da", acNormal, , "[Cod_Tamin_Konande]=" & !Cod_Tamin_Konande, , acdialog
End If
.Update
.MoveNext
Loop
end with
</code></pre>

but when the form gets open I cant change records, all the record get locked
other wise if I open the form in acWindowNormal mode every thing is right

对话表单的记录已被锁定

I try to create another query for the loop I use but it's not working.

答案1

得分: 2

但是为什么在打开表单的循环中使用编辑命令?

你有这样:

With rs
    .MoveFirst
    Do While Not rs.EOF
        .Edit       &lt;------ 为什么?这没做任何事情????请解释!!!

        If (!Tahvil_Tmp = True) * (!Az_Tankhah = False) Then
            If DLookup(&quot;[Saff_Arzyabi_2]&quot;, &quot;Arzyabi_Tamin_Konande_sh&quot;, _
                &quot;val([Cod_Tamin_Konande]) = &#39;&quot; &amp; !Cod_Tamin_Konande &amp; &quot;&#39;&quot;) = True Then
                DoCmd.OpenForm &quot;Arzyabi_Tamin_Konande_da&quot;, acNormal, , &quot;[Cod_Tamin_Konande]=&quot; &amp; !Cod_Tamin_Konande, , acDialog
            End If
        .Update
        .MoveNext
    Loop
End With

所以,这个 .Edit 命令是做什么的呢?它实际上只是锁定记录,但这没有任何价值,没有做任何有价值的事情,你也没有做任何编辑?所以,为什么?那个 .edit 命令的原因是什么?(除了锁定记录之外!!!)。

移除那个编辑命令,你正在启动某个表单,那个表单应该能做任何它想做的事情!!!!

一个猜测:

那段代码应该是这样的:

With rs
    .MoveFirst
    Do While Not rs.EOF
        If (!Tahvil_Tmp = True) * (!Az_Tankhah = False) Then
            If DLookup(&quot;[Saff_Arzyabi_2]&quot;, &quot;Arzyabi_Tamin_Konande_sh&quot;, _
                &quot;val([Cod_Tamin_Konande]) = &#39;&quot; &amp; !Cod_Tamin_Konande &amp; &quot;&#39;&quot;) = True Then
                DoCmd.OpenForm &quot;Arzyabi_Tamin_Konande_da&quot;, acNormal, , &quot;[Cod_Tamin_Konande]=&quot; &amp; !Cod_Tamin_Konande, , acDialog
            End If
        .MoveNext
    Loop
End With

Me.Refresh   &lt;---- 在对话框提示完成后显示表单中的任何更新数据。
英文:

But why are you using a edit command in the loop that opens that form?

You have this:

With rs
    .MoveFirst
    Do While Not rs.EOF
        .Edit       &lt;------ WHY? This does nothing?????? explain!!!

        If (!Tahvil_Tmp = True) * (!Az_Tankhah = False) Then
            If DLookup(&quot;[Saff_Arzyabi_2]&quot;, &quot;Arzyabi_Tamin_Konande_sh&quot;, _
                &quot;val([Cod_Tamin_Konande]) = &#39;&quot; &amp; !Cod_Tamin_Konande &amp; &quot;&#39;&quot;) = True Then
                DoCmd.OpenForm &quot;Arzyabi_Tamin_Konande_da&quot;, acNormal, , &quot;[Cod_Tamin_Konande]=&quot; &amp; !Cod_Tamin_Konande, , acDialog
            End If
        .Update
        .MoveNext
    Loop
End With

So, what does that .Edit command do? All it REALLY does is wind up locking the reocrd, but then that does ZERO value, does nothing of value, and you don't do any edits??? So, why? What is the reason for that .edit command? (except to lock the reocrd!!!).

Remove that edit command, you are launching some form, and that form should be able to do whatever it likes to do!!!!

A wild good guess in the dark??

That code should be this:

With rs
    .MoveFirst
    Do While Not rs.EOF
        If (!Tahvil_Tmp = True) * (!Az_Tankhah = False) Then
            If DLookup(&quot;[Saff_Arzyabi_2]&quot;, &quot;Arzyabi_Tamin_Konande_sh&quot;, _
                &quot;val([Cod_Tamin_Konande]) = &#39;&quot; &amp; !Cod_Tamin_Konande &amp; &quot;&#39;&quot;) = True Then
                DoCmd.OpenForm &quot;Arzyabi_Tamin_Konande_da&quot;, acNormal, , &quot;[Cod_Tamin_Konande]=&quot; &amp; !Cod_Tamin_Konande, , acDialog
            End If
        .MoveNext
    Loop
End With

me.Refresh   &lt;---- show any update dated in our form after dialog
             prompts are done.

huangapple
  • 本文由 发表于 2023年2月19日 18:20:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/75499418.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定