Dim msg, button, title, response
msg = "Do you really want to exit?"
button = vbYesNo + vbDefaultButton2
title = "Confirm Exit"
response = MsgBox(msg, button, title)
If response = vbYes Then
'what to do if yes
Else
'what to do if not
End If
There are many threads on the subject. It all depends on how vigilant you want to be. There are many ways to exit Access so if you are serious you need to address them all.
ie: Clicking an exit button
Clicking the X on the form bar
Just clicking the X on the Access window.