我可以添加 UI 操作确认吗?

Can I add a UI action confirmation?

我有一个显示记录(大约 40 个字段)的表单。我有一个按钮可以在需要稍微更改的情况下复制记录(即 A541AB 变为 A541AC)。我在互联网上看到了几个解决方案实例,但我找不到适用于此 UI 操作的解决方案。是否可以创建一个确认框,询问他们是否确定要复制记录?目前,该按钮是使用宏设计的,因为我对 Access 不是很好VBA。

您需要在 VBA 中通过设置标志来处理自动更新来执行此操作。单击按钮后询问用户并在答案为是时保存。

'Set a flag for manual update
Private mIsUserUpdate As Boolean 'Flag

'Cancel auto-update
Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Not mIsUserUpdate Then Cancel = True
End Sub

'Save Button - Change 'YourButtonName'
Private Sub YourButtonName_Click()
    If MsgBox("Are you sure you want to duplicate the record?", vbYesNo + vbQuestion, "Confirm") = vbYes Then
        mIsUserUpdate = True  'flag ON
        DoCmd.RunCommand acCmdSaveRecord
    End If
    mIsUserUpdate = False 'flag OFF again
End Sub