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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with form event

Status
Not open for further replies.

neilmcmor

Technical User
Aug 9, 2007
30
GB
I have a Form that uses a BeforeUpdate event to offer the user the chance to undo changes before saving. The code below works however I do not wish the form to clear its contents once the user clicks yes as I would like the user to have the ability to then go onto add data into the subform contained within this form. Any Idea?

Private Sub Form_BeforeUpdate(Cancel As Integer)

'Provide the user with the option to save/undo
'changes made to the record in this form

If MsgBox("Clicking YES will save these deatils!" _
& vbCrLf & vbCrLf & "Do you wish to commit these changes?", _
vbYesNo, "Do You Require These Changes Made...") = vbYes Then
DoCmd.Save
Else
DoCmd.RunCommand acCmdUndo
End If

End Sub
 
I would guess that you just want to exit the sub and return to the form?

Maybe:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

'Provide the user with the option to save/undo
'changes made to the record in this form

If MsgBox("Clicking YES will save these deatils!" _
& vbCrLf & vbCrLf & "Do you wish to commit these changes?", _
vbYesNo, "Do You Require These Changes Made...") = vbYes Then
DoCmd.Save
Else
 [b]Exit[/b]
End If

End Sub

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins
 
Otherway around Lespaul. Exit the form and go to the sub
 
What about this ?
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Clicking YES will save these deatils!" _
& vbCrLf & vbCrLf & "Do you wish to commit these changes?", _
vbYesNo, "Do You Require These Changes Made...") <> vbYes Then
  Cancel = True
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top