如果我不关闭表单,MS Access表单的记录集不会更新?
问题描述:
我正在使用此代码从连续表单向表中插入数据。 上单击事件:如果我不关闭表单,MS Access表单的记录集不会更新?
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
If Not (rs.EOF And rs.BOF) Then
Do Until rs.EOF = True
If rs!Cont_Selct = True Then
DoCmd.SetWarnings False
DoCmd.RunSQL "insert into tbl_favconn (fav_name,cont_id) values('" & Me.txtGroupSrch & "','" & rs!Cont_id & "')"
DoCmd.SetWarnings True
rs.Edit
rs!Cont_Selct = False
rs.Update
End If
rs.MoveNext
Loop
MsgBox "done"
rs.Close
Set rs = Nothing
End If
当我打开了它第一次工作正常的形式,但是当我尝试选择 它不接受其他联系,所以我必须关闭表并重新打开,以 选择其他联系人添加它们。
任何建议,非常感谢。
答
我得到了答案。
其带来的记录如下:
开始循环之前。
rs.movefirst
If Not (rs.EOF And rs.BOF) Then
'' rest of the code
您为窗体的所有记录重置'Cont_Selct',那么您可能会选择什么? – Gustav
感谢您的重播Gustav,我的意思是手动重新选择不接受执行代码后,所以我必须关闭表单并重新打开它。 –