Forgive me if this is a stupid question - I am new to foraying into the VB side of Access97<br>
<br>
I have created a small Rolodex database with one front end form that folks will use. I have set up three "states" of the form, View Only, Edit Mode, and Add a New Record Mode...all within one form. I have these differnt states activated by buttons, and have the fields lock or unlock with the "enabled" property on the buttons. The only part I can't get is that when the user goes into edit or new record mode, writes or deletes stuff, and then I give them a dialogue box that asks if they want to save or cancel, I don't understand how to do a true cancel and not have the new record added anyway, or the editing added anyway. I realize that as soon as someone types or deletes something, it's being instantly done in the source table, so is there some VBA way to undo that?? Like put the changes into some temporary la la land? As an example, here is the code I have for the save/cancel button in edit mode...<br>
<br>
Private Sub btnSaveEdit_Click()<br>
On Error GoTo Err_btnSaveEdit_Click<br>
Dim Savechoice<br>
<br>
Savechoice = MsgBox("Do you want to save your changes?", vbYesNo, "Save"<br>
<br>
If Savechoice = vbYes Then<br>
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70<br>
<br>
Else<br>
DoCmd.CancelEvent<br>
<br>
End If<br>
Exit_btnSaveEdit_Click:<br>
Exit Sub<br>
<br>
Err_btnSaveEdit_Click:<br>
MsgBox Err.Description<br>
Resume Exit_btnSaveEdit_Click<br>
<br>
End Sub<br>
<br>
Please have mercy on my green-ness, o great ones! <br>
<br>
<br>
I have created a small Rolodex database with one front end form that folks will use. I have set up three "states" of the form, View Only, Edit Mode, and Add a New Record Mode...all within one form. I have these differnt states activated by buttons, and have the fields lock or unlock with the "enabled" property on the buttons. The only part I can't get is that when the user goes into edit or new record mode, writes or deletes stuff, and then I give them a dialogue box that asks if they want to save or cancel, I don't understand how to do a true cancel and not have the new record added anyway, or the editing added anyway. I realize that as soon as someone types or deletes something, it's being instantly done in the source table, so is there some VBA way to undo that?? Like put the changes into some temporary la la land? As an example, here is the code I have for the save/cancel button in edit mode...<br>
<br>
Private Sub btnSaveEdit_Click()<br>
On Error GoTo Err_btnSaveEdit_Click<br>
Dim Savechoice<br>
<br>
Savechoice = MsgBox("Do you want to save your changes?", vbYesNo, "Save"<br>
<br>
If Savechoice = vbYes Then<br>
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70<br>
<br>
Else<br>
DoCmd.CancelEvent<br>
<br>
End If<br>
Exit_btnSaveEdit_Click:<br>
Exit Sub<br>
<br>
Err_btnSaveEdit_Click:<br>
MsgBox Err.Description<br>
Resume Exit_btnSaveEdit_Click<br>
<br>
End Sub<br>
<br>
Please have mercy on my green-ness, o great ones! <br>
<br>