H
hermanko
Hi,
I have a form that is used for data entry into my underlying table. I
have AllowAdditions turned ON as well as Yes to Data Entry in the form
properties. I am using the BeforeUpdate event so that the user can
click OK or Cancel to save or undo any changes made on a new record:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save entry?", vbOKCancel + vbDefaultButton1) <> vbOK
Then
Cancel = True
Me.Undo
Me![File Code].SetFocus ' resets cursor to first field on form
called [File Code]
End If
End Sub
The issue I have is that I also want a command button for Save and
Cancel, so that the user doesn't need to TAB or ENTER all the way down
to the last record before triggering the BeforeUpdate event (as some
fields may not require info so the user can just click Save or Cancel
"prematurely").... but as I have it now, as soon as I click on, say, my
Cancel button, it'll trigger the above event as focus has left the new
record. Is there a way to bypass that if I just want to Cancel and
immediately close that form? Conversely, is there a way to bypass that
event so that I can just Save and immediately close the form? 'Cuz it
just doesn't make sense to have user click Cancel and then still have
the msgbox ask Save Entry?...if they click OK then effectively they
have saved the record by clicking Cancel!
I hope my problem is stated clear and if anyone can help me out that
would be greatly appreciated.
Herman
I have a form that is used for data entry into my underlying table. I
have AllowAdditions turned ON as well as Yes to Data Entry in the form
properties. I am using the BeforeUpdate event so that the user can
click OK or Cancel to save or undo any changes made on a new record:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save entry?", vbOKCancel + vbDefaultButton1) <> vbOK
Then
Cancel = True
Me.Undo
Me![File Code].SetFocus ' resets cursor to first field on form
called [File Code]
End If
End Sub
The issue I have is that I also want a command button for Save and
Cancel, so that the user doesn't need to TAB or ENTER all the way down
to the last record before triggering the BeforeUpdate event (as some
fields may not require info so the user can just click Save or Cancel
"prematurely").... but as I have it now, as soon as I click on, say, my
Cancel button, it'll trigger the above event as focus has left the new
record. Is there a way to bypass that if I just want to Cancel and
immediately close that form? Conversely, is there a way to bypass that
event so that I can just Save and immediately close the form? 'Cuz it
just doesn't make sense to have user click Cancel and then still have
the msgbox ask Save Entry?...if they click OK then effectively they
have saved the record by clicking Cancel!
I hope my problem is stated clear and if anyone can help me out that
would be greatly appreciated.
Herman