Skip to content

Instantly share code, notes, and snippets.

@eggist77
Last active August 10, 2021 12:34
Show Gist options
  • Save eggist77/bc1d5d40c37a31b0ecfd0a3d8c96284d to your computer and use it in GitHub Desktop.
Save eggist77/bc1d5d40c37a31b0ecfd0a3d8c96284d to your computer and use it in GitHub Desktop.
vba vba_access_vba.vb
'保存ボタン
Private Sub saveBtn_Click()
DoCmd.RunCommand acCmdSaveRecord
End Sub
'キャンセルボタン
Private Sub canselBtn_Click()
Me.Undo
End Sub
'終了ボタン
Private Sub closeBtn_Click()
If Me.Dirty Then
If MsgBox("データが更新されてます。保存して終了しますか。", vbOKCancel) = vbCancel Then
Exit Sub
Else
saveBtn_Click()
End If
End If
DoCmd.Close
End Sub
' 更新前確認
Private Sub Form_BeforeUpdate(Cancel As Integer)
res = MsgBox("データを更新しますか", vbYesNo)
If res = vbNo Then
Cancel = True
Me.Undo
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment