英文:
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 <------ 为什么?这没做任何事情????请解释!!!
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
所以,这个 .Edit 命令是做什么的呢?它实际上只是锁定记录,但这没有任何价值,没有做任何有价值的事情,你也没有做任何编辑?所以,为什么?那个 .edit 命令的原因是什么?(除了锁定记录之外!!!)。
移除那个编辑命令,你正在启动某个表单,那个表单应该能做任何它想做的事情!!!!
一个猜测:
那段代码应该是这样的:
With rs
.MoveFirst
Do While Not rs.EOF
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
.MoveNext
Loop
End With
Me.Refresh <---- 在对话框提示完成后显示表单中的任何更新数据。
英文:
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 <------ WHY? This does nothing?????? explain!!!
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
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("[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
.MoveNext
Loop
End With
me.Refresh <---- show any update dated in our form after dialog
prompts are done.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论