Close Message Box

Sandi09

New member
Local time
Today, 13:22
Joined
Mar 19, 2011
Messages
9
For one or more of my forms, I have a Message Box feature in place for editing the form. Box Title/Heading "Changes Made", message reads

Changes have been made to this record.

Do you want to save these changes?

Yes No


However, the "X" in the right hand corner is grayed out, but I would like it to be enabled everytime this message box appears so I wouldnt have to just choose between yes or no, just close the message box and return to the form as it is.

Can I please get some help on this, I have looked everywhere but can't get the right code for it.

Your help will be appreciated:)
 
It seems you want to have a third option: cancel the save operation. Then make a messagebox that allows you to do that: vbYesNoCancel
 
The "X" close option is to return to the form as it was before the message box appeared in the case I don't want to save what was edited or don't want to remove what I added, I just want to close that box when it appears. I hope I'm making sense here. Not sure why I need another message box to cancel the initial save box?!
 
Not sure why I need another message box to cancel the initial save box?!
No, you don't need another message box. What you were being told is you can use the vbYesNoCancel message box instead of the vbYesNo one. But you aren't going to get the close button. The Access message box doesn't work that way. You would need to create your own form to use as a message box in order to do that.
 
Ok, so now I know can't get that "x" feature to work on Msg box. For the vbYesNoCancel, I input this code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Select Case MsgBox("Save?", vbYesNoCancel)
Case vbYes 'go ahead and save.
'do nothing
Case vbNo 'undo the changes.
Cancel = True
Me.Undo
Case vbCancel
Cancel = True
End Select
End Sub

The yes and no works ok, but the cancel function does't allow me to go to the next record or find a record (with my cmd.find), when I try to find or go to next record the msg box keeps reappearing not allowing to move to next record or find.

Someone knows why this keeps happening, do tell
 
You got what you asked for - a return to the form "as is", with the user's latest changes remaining but not saved. That means that the form remains dirty (=having unsaved changes) , and therefore Access attempts to save the record when you move away from it. That is why you hit the BeforeUpdate again.
 

Users who are viewing this thread

Back
Top Bottom