My Assistant
![]() ![]() |
|
|
Oct 19 2005, 11:26 AM
Post
#1
|
|
|
UtterAccess Member Posts: 38 |
I've got a form (frmEntry) with a subform (frmInspection). When a user chooses to exit without saving, the record is still saved. I've got the Exit button on frmEntry and the only way it is exiting without saving is if the user doesn't touch the subform. here is my code for my exit button:
Private Sub cmdExit_Click() On Error GoTo Err_cmdExit_Click Me.Undo DoCmd.Close Exit_cmdExit_Click: Exit Sub Err_cmdExit_Click: MsgBox Err.Description Resume Exit_cmdExit_Click End Sub If the user enters something on the subform, then decides to exit, a message box pops up asking "Do you want to save?" and even when clicking "no", the record is still saved. ANY ideas?? |
|
|
|
Oct 19 2005, 11:40 AM
Post
#2
|
|
|
UtterAccess VIP Posts: 9,209 From: Maryland |
Add Me!sfrmName.Form.Undo.
|
|
|
|
Oct 19 2005, 11:51 AM
Post
#3
|
|
|
UtterAccess Member Posts: 38 |
Thanks for your quick response. Unfortunately, I am still having the same problem. Should I put the code somewhere else?
Private Sub cmdExit_Click() On Error GoTo Err_cmdExit_Click Me.Undo Me!sfrmInspection.Form.Undo DoCmd.Close Exit_cmdExit_Click: Exit Sub Err_cmdExit_Click: MsgBox Err.Description Resume Exit_cmdExit_Click End Sub |
|
|
|
Oct 19 2005, 11:56 AM
Post
#4
|
|
|
UtterAccess VIP Posts: 9,209 From: Maryland |
That is the only way I know how to use Undo on a subform. I use it and have a problem occasionally, but most of the time it does work. The other option would be to delete the record from the tbl the sfrm is bound to on the vbNo from your save message.
|
|
|
|
Oct 19 2005, 11:58 AM
Post
#5
|
|
|
UtterAccess Member Posts: 38 |
Ok, I'll mess around with it a little more........how would I delete the record from the table on the vbNo?
|
|
|
|
Oct 19 2005, 12:10 PM
Post
#6
|
|
|
UtterAccess VIP Posts: 18,396 From: Oklahoma City, Oklahoma |
Your code will work fine for a form that does not have a sub form..
When you have a form with a sub form, Access automatically saves the parent record when you enter the sub form. It must do this to insure the at the parent record has been created so the sub form records can have a record to link to. The method ("logic") of what you want to do is difficult to do when the form/sub form design uses forms that are "bound" to tables. Because you are dealing with multiple records when using a form with sub forms and Access automatically saves a record when you change records or enter a sub form, you will probably need to try this using a different method . Hope this helps... |
|
|
|
Oct 19 2005, 12:29 PM
Post
#7
|
|
|
UtterAccess Guru Posts: 501 |
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 24th May 2013 - 06:01 PM |