Don't save form until record is saved on second form (1 Viewer)

Zydeceltico

Registered User.
Local time
Today, 17:48
Joined
Dec 5, 2017
Messages
843
Hi. You don't need to reach back to form 1 because you already passed the ID to form 2, you should be able to use the same information to delete the unwanted record.

I never figured out how to do this elegantly.

On a given secondary form's "Save" button I have this

RunCommand acCommandSaveRecord
DoCmd.Close

And then on each secondary form's Unload event I have

DoCmd.Close acForm, "frmInspectionEvent", acSaveYes

So I tried putting all of that code on click event of the Save button like this:

DoCmd.Close acForm, Me.Name, acSaveYes
DoCmd.Close acForm, "frmInspectionEvent", acSaveYes

And then made a "Cancel" button that has this code on the click:

DoCmd.Close acForm, Me.Name, acSaveNo
DoCmd.Close acForm, "frmInspectionEvent", acSaveNo

This works for not saving the secondary form but the record is still saved to the table of the original calling form.

Is there some other syntax I can use to replace DoCmd.Close acForm, "frmInspectionEvent", acSaveNo so that record from the calling form is deleted?

I have this code on the original calling form's Before Update event:

Code:
If Me.Dirty Then
If MsgBox ("Do you want to continue?", vbYesNo + vbQuestion, "Save Record" = vbNo Then
Me.Undo
End If
End If

Is there something like this I can put on the calling form's Close or Unload event that asks "Do you want to save?" and if I click No it will delete the current record in the table of the calling form?

Remember Form1 (calling form) and Form2 (secondary form) are both open at same time.

Thanks!

Tim
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:48
Joined
Oct 29, 2018
Messages
21,358
Hi Tim. If you could post a sample copy of your db with test data, we would be able to better help you get to a working solution faster.
 

Zydeceltico

Registered User.
Local time
Today, 17:48
Joined
Dec 5, 2017
Messages
843
Hi Tim. If you could post a sample copy of your db with test data, we would be able to better help you get to a working solution faster.


Here it is. On the opening menu click "Inspections." When that form opens up you'll need to fill in 4 cbo's (it will tell you which ones). Then click "Mill Inspection" as that is the form where I have been testing the code.
 

Attachments

  • QC DB 3-28-19.zip
    300.3 KB · Views: 42

theDBguy

I’m here to help
Staff member
Local time
Today, 14:48
Joined
Oct 29, 2018
Messages
21,358
Okay, when I click on "Mill Inspection," it asks "Are you committing to an inspection?" What does this mean?
 

Zydeceltico

Registered User.
Local time
Today, 17:48
Joined
Dec 5, 2017
Messages
843
Okay, when I click on "Mill Inspection," it asks "Are you committing to an inspection?" What does this mean?

It's giving the other inspectors an out. But now that you mention it - it may well be saving the record right then.

Reviewing the code on the Before Update event for that form it is in fact saving the record right then. Maybe I should not do that? If I don't save right then and wait to save on the click event of the save button on the secondary form would it make it easier to undo the data on the original form?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:48
Joined
Oct 29, 2018
Messages
21,358
Probably. Give it a try and let us know if it helps you fix the problem or not. Then, I'll see what I can figure out with your demo. Good luck!
 

Zydeceltico

Registered User.
Local time
Today, 17:48
Joined
Dec 5, 2017
Messages
843
Probably. Give it a try and let us know if it helps you fix the problem or not. Then, I'll see what I can figure out with your demo. Good luck!

Thank You! I am so culpable of not seeing the forest for the trees! :)
 

Users who are viewing this thread

Top Bottom