Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

confirmation msgbox

Status
Not open for further replies.

MykH

Technical User
Sep 18, 2001
8
0
0
US
Hello All,

Any ideas on creating a confirmation message box that will confirm with the user if they wish to save a record. And Also, will not save the record if the "X" is clicked. I "borrowed" the following code below, which seems to solve the confirmation end, but the record stills saves if the "X" is clicked, at time saving an incomplete entry. Any help would be appreciated :)


Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click

Dim intPress As Integer
DoCmd.SetWarnings False

intPress = MsgBox("Are you sure you wish to save this entry?", vbWarning + vbOKCancel, "warning")
If intPress = vbOK Then

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_cmdSave_Click:

End If

DoCmd.SetWarnings True
Exit Sub

Err_cmdChatSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click

End Sub


Thanks,
MykH

 
Well, if your form and controls are bound to a source, the data on the form will automatically update whether the user clicks save or not, as you just disovered.

Therefore, I would take a different approach to this and confirm whether or not the user wants to 'Edit' the form. And/or, you could use the Before_Update event of the form to confirm with the user if they want to save their changes to record or not.

If the user does not want to save, you can employ the me.Undo, OR the docmd.Cancelevent option (within that event procedure) that will return the form to its original state.

Hope that helps,
Gary
gwinn7
A+,Network+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top