Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 03-14-2019, 07:37 PM   #16
Zydeceltico
Newly Registered User
 
Join Date: Dec 2017
Location: Pittsburgh, PA
Posts: 583
Thanks: 432
Thanked 6 Times in 6 Posts
Zydeceltico is on a distinguished road
Re: Don't save form until record is saved on second form

Quote:
Originally Posted by theDBguy View Post
Hi. There you go, you may have answered the question of where to put the code. If you add a ďcancelĒ button on your inspection forms, you can use its Click event to delete the parent record if thereís no related child records in the other tables.
Please accept my - current state. :-)

Any even remote idea what the code looks like on that cancel button to reach across to the originating form to delete the parent record?

I am soooo grateful that you are following this post with me, It's one of the "last big hurdles."

Zydeceltico is offline   Reply With Quote
Old 03-14-2019, 07:41 PM   #17
Zydeceltico
Newly Registered User
 
Join Date: Dec 2017
Location: Pittsburgh, PA
Posts: 583
Thanks: 432
Thanked 6 Times in 6 Posts
Zydeceltico is on a distinguished road
Re: Don't save form until record is saved on second form

Quote:
Originally Posted by Zydeceltico View Post
Please accept my - current state. :-)

Any even remote idea what the code looks like on that cancel button to reach across to the originating form to delete the parent record?

I am soooo grateful that you are following this post with me, It's one of the "last big hurdles."

Or more specifically - - How do I reference back from Form 2 to Form 1?
Zydeceltico is offline   Reply With Quote
Old 03-14-2019, 07:45 PM   #18
Zydeceltico
Newly Registered User
 
Join Date: Dec 2017
Location: Pittsburgh, PA
Posts: 583
Thanks: 432
Thanked 6 Times in 6 Posts
Zydeceltico is on a distinguished road
Re: Don't save form until record is saved on second form

Google tells me to look to look at Unmatched Query Wizard and convert to Delete query. I'll play with that for awhile.

Zydeceltico is offline   Reply With Quote
Old 03-14-2019, 08:06 PM   #19
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,131
Thanks: 25
Thanked 551 Times in 539 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Don't save form until record is saved on second form

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.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
Zydeceltico (03-14-2019)
Old 03-15-2019, 03:43 AM   #20
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 1,546
Thanks: 25
Thanked 466 Times in 443 Posts
MajP will become famous soon enough MajP will become famous soon enough
Re: Don't save form until record is saved on second form

The purpose of the code I posted is that you cannot do a simple unmatched query. You can have inspections in multiple tables. So the query checks if have any child inspection is in any table.

https://www.access-programmers.co.uk...32&postcount=9

If you do not have any inspection and return to the main form, you now can decide to delete the InspectionEvent. You can run the check at any time.
MajP is offline   Reply With Quote
The Following User Says Thank You to MajP For This Useful Post:
Zydeceltico (03-24-2019)
Old 03-28-2019, 10:06 AM   #21
Zydeceltico
Newly Registered User
 
Join Date: Dec 2017
Location: Pittsburgh, PA
Posts: 583
Thanks: 432
Thanked 6 Times in 6 Posts
Zydeceltico is on a distinguished road
Re: Don't save form until record is saved on second form

Quote:
Originally Posted by theDBguy View Post
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
Zydeceltico is offline   Reply With Quote
Old 03-28-2019, 10:12 AM   #22
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,131
Thanks: 25
Thanked 551 Times in 539 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Don't save form until record is saved on second form

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.

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
Zydeceltico (03-28-2019)
Old 03-28-2019, 10:22 AM   #23
Zydeceltico
Newly Registered User
 
Join Date: Dec 2017
Location: Pittsburgh, PA
Posts: 583
Thanks: 432
Thanked 6 Times in 6 Posts
Zydeceltico is on a distinguished road
Re: Don't save form until record is saved on second form

Quote:
Originally Posted by theDBguy View Post
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.
Attached Files
File Type: zip QC DB 3-28-19.zip (300.3 KB, 3 views)
Zydeceltico is offline   Reply With Quote
Old 03-28-2019, 10:33 AM   #24
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,131
Thanks: 25
Thanked 551 Times in 539 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Don't save form until record is saved on second form

Okay, when I click on "Mill Inspection," it asks "Are you committing to an inspection?" What does this mean?
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 03-28-2019, 10:36 AM   #25
Zydeceltico
Newly Registered User
 
Join Date: Dec 2017
Location: Pittsburgh, PA
Posts: 583
Thanks: 432
Thanked 6 Times in 6 Posts
Zydeceltico is on a distinguished road
Re: Don't save form until record is saved on second form

Quote:
Originally Posted by theDBguy View Post
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?
Zydeceltico is offline   Reply With Quote
Old 03-28-2019, 10:38 AM   #26
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,131
Thanks: 25
Thanked 551 Times in 539 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Don't save form until record is saved on second form

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!
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
Zydeceltico (03-28-2019)
Old 03-28-2019, 10:39 AM   #27
Zydeceltico
Newly Registered User
 
Join Date: Dec 2017
Location: Pittsburgh, PA
Posts: 583
Thanks: 432
Thanked 6 Times in 6 Posts
Zydeceltico is on a distinguished road
Re: Don't save form until record is saved on second form

Quote:
Originally Posted by theDBguy View Post
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! :-)

Zydeceltico is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable the form controls if the record's field Saved is true Derek Modules & VBA 2 07-25-2016 08:57 AM
Create a button in a form to add new record that will be saved in other table pauld118 Forms 8 06-28-2011 02:13 PM
New record saved with no record on child form jdcallejas General 1 02-27-2009 07:55 AM
Would like my save button to display Record has been saved hardhitter06 Modules & VBA 34 01-30-2009 09:08 AM
two subforms, that i only want visible after record on main form is saved... edzigns Modules & VBA 6 08-28-2002 01:03 PM




All times are GMT -8. The time now is 01:06 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World