J
JamesJ
Access 2007 sp2
I'm using the following code I found on the web, on a Single Form, to have the user
choose to either save the record or not save the record or close the
message box and continue editing:
Private Sub cmdSaveAndClose_Click()
If Me.Dirty Then
Dim BlnOutcome As Integer
BlnOutcome = MsgBox("Record(s) have been added or changed." _
& vbCrLf & "Save the Changes?", vbYesNoCancel + vbQuestion, "Record Change")
Select Case BlnOutcome
Case vbCancel
Me!FieldName.SetFocus
Case vbYes
DoCmd.Close
Case vbNo
Me.Undo
DoCmd.Close
End Select
Else
DoCmd.Close
End If
End Sub
This works ok but I need to figure out what to do if the user hits the page-up or
page-down key and moves off the current record.The way it is now if the user moves
off the record the record gets saved. I want to be able to choose to save or not
but without closing the form when the user goes to another record.
I still want the option to continue to edit the current record even though the user
tries to move off the record.
Any help will be appreciated,
James
I'm using the following code I found on the web, on a Single Form, to have the user
choose to either save the record or not save the record or close the
message box and continue editing:
Private Sub cmdSaveAndClose_Click()
If Me.Dirty Then
Dim BlnOutcome As Integer
BlnOutcome = MsgBox("Record(s) have been added or changed." _
& vbCrLf & "Save the Changes?", vbYesNoCancel + vbQuestion, "Record Change")
Select Case BlnOutcome
Case vbCancel
Me!FieldName.SetFocus
Case vbYes
DoCmd.Close
Case vbNo
Me.Undo
DoCmd.Close
End Select
Else
DoCmd.Close
End If
End Sub
This works ok but I need to figure out what to do if the user hits the page-up or
page-down key and moves off the current record.The way it is now if the user moves
off the record the record gets saved. I want to be able to choose to save or not
but without closing the form when the user goes to another record.
I still want the option to continue to edit the current record even though the user
tries to move off the record.
Any help will be appreciated,
James