Is there an event that can detect when a user exits from adding a new record without adding it?

I have a form that I use to display customer records and a subform (continuous records) to display associated asset records. I would like the sub form to not display a blank record so I have set AllowAdditions to No. I have added button to add a record that sets AllowAdditions to True. That part works fine but when the user exits that record, either after adding it or not, what I want is to set AllowAdditions to False again. What event(s) would I use to do that? Or is there a better way?
Rob4077Asked:
Who is Participating?
 
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
<<What event(s) would I use to do that? Or is there a better way? >>

  You'd need two check in two places:

1. The Lostfocus event of the subform control on the main form.
2. The OnCurrent event of the subform.

  The first covers them moving out of the subform.  The second covers them moving into another record within the subform.

JimD.
0
 
clarkscottCommented:
On the form, in the AFTERUPDATE event - set your allowadditions = false

Scott C
0
 
RunriggerCommented:
Afterupdate won't work if the blank record has not transitioned to a dirty state (i.e. not attempt to add a value in any field).

if the user moves to a previous record, allowadditions will still be true!
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Rob4077Author Commented:
That half works. If I add a new record it works but if I decide to escape and cancel out of the process by clicking on an existing record the AllowAdditions remains set to true. Do I have to live with that or is there a way around it?
0
 
clarkscottCommented:
It seems the AfterUpdate won't fire unless the record IS in a dirty state???  Perhaps afterinsert would work.
Scott C
0
 
clarkscottCommented:
Maybe ONCurrent. - try it.
Scott C
0
 
Rob4077Author Commented:
I've tried them but they're not reliable so I think I will just stick to leaving allowadditions to true and train the operators to interpret the form.

Thanks for your very kind assistance.
0
 
Rob4077Author Commented:
Thanks Jim. I tried that and it looks like it did the trick. Are you still the moderator for this page? I need to get the question re-opened and the points awarded to you.
0
 
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
<<Thanks Jim. I tried that and it looks like it did the trick. Are you still the moderator for this page? I need to get the question re-opened and the points awarded to you. >>

 Don't worry about the points...glad to hear it worked for you.

 And yes, I'm still a zone advisor.

JimD.
0
 
Rob4077Author Commented:
Jim, I am happy to award all the points to you since you have provided the correct answer. I will leave it to you if you want to fix it. It may be worth it for the sake of the next person who researches this question.
0
 
Rob4077Author Commented:
Thanks for providing a working solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.