我有一个正在更新表格的表格。最终用户通过另一个表单(即所谓的搜索表单)返回表单。我在此搜索表单中创建了一个组合框,以选择以前的记录和其他一些需要更新的字段。当我单击“更新”时,我希望这些记录更新上一行(在“搜索表单”组合框中选择,但它总是创建新记录而不是更新所选记录。您知道我的代码中缺少什么吗? 预先谢谢你。
Public Sub find_record_Click()
Dim strMsg As String
Dim iResponse As Integer
Dim rst2 As DAO.Recordset
strMsg = "Do you wish to save the changes?" & Chr(10)
strMsg = strMsg & "Click Yes to Save or No to Discard changes."
iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")
If iResponse = vbNo Then
DoCmd.RunCommand acCmdUndo
Cancel = True
Else
Set rst2 = Where = search_candidate
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close 'acForm, Me.Name, acSaveYes
End If
End Sub