Normal Topic Orphan Records (Read 941 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Orphan Records
Jun 16th, 2009 at 12:54pm
Print Post Print Post  
I have two suborms, one of the forms makes new records while passes through certain element when condition is right. Once records are created and the user escape or abort, the created records will still remain. It would not bother but it will show up in the report that is linked using the key field. Any suggestion to deal with this using proper codeing? Thanks.
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Orphan Records
Reply #1 - Jun 21st, 2009 at 3:03am
Print Post Print Post  
It's not a perfect solution, but...
Have you tried using a FormCommit("") in the main form's programming just after it creates the subrecords? At least this way, you will have a parent form linked to those subrecords, and if another parent record tries to reuse the key value, you can notify the user.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Orphan Records
Reply #2 - Jun 21st, 2009 at 3:21am
Print Post Print Post  
Add a hidden field to the subrecords that indicates that the record is valid and parented. Set that field on all the children when the user commits the parent. When the report is run, set your search spec to check that field and exclude records on which it is not set. Later, you can use the same field to mass delete the orphaned children.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Orphan Records
Reply #3 - Jun 21st, 2009 at 4:09am
Print Post Print Post  
Thanks Mark and Carl. Does that mean that I should use formcommit ("") and fill out that hidden field in Child records just before saving the parent record? If parent record is not saved for whatever reasons, the hidden field will not have the proper value and they can be safely deleted later on.  This should work. Thanks.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Orphan Records
Reply #4 - Jun 21st, 2009 at 4:32am
Print Post Print Post  
Whether you use a programmed commit depends on whether you want to allow the user to be able to abandon the parent using escape or not.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Orphan Records
Reply #5 - Jun 22nd, 2009 at 7:26pm
Print Post Print Post  
Mark, your precise explanation about Formcommit ( ) is quite clear. This should certainly help to avoid creating orphan records and deal with the one those are inadvertently created. Thanks.
  
Back to top
 
IP Logged