Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) using formfieldvalue to post to the correct form (Read 1839 times)
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
using formfieldvalue to post to the correct form
Nov 9th, 2006 at 11:30pm
Print Post Print Post  
Should I be concerned that Sesame may post values to an incorrect form when using the Formfieldvalue command to post data to a subform with the current record open in ADD mode and a different record opened using the same form, but in Search/update mode? (both Add and Updates modes open displaying the same form, but different records, simultaneously)

Is there a chance Sesame would post my data to the wrong form? Is there way to safeguard aginst this sort of thing?

I'm asking becuase I'm still having a problem with natural linked records disappearing and/or attaching themselves to incorrect parents.

Thanks,
Steve
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: using formfieldvalue to post to the correct fo
Reply #1 - Nov 10th, 2006 at 12:14am
Print Post Print Post  
You can follow the form name with a mode specifier: "FormName:(add)", "FormName:(update)", or "FormName:(search)". But even without the specifier, if there is more than one form instance open in different modes, it will select the child of the current form before it will select the same form standalone. Further, if there is some confusion, the path to the form can be specified, as in "ParentForm!ChildForm".

It checks in the following order:
If zero length name (i.e.: "")
{
  Use current form
}
Check for a mode specifier
Check all open forms
If there are more than one likely forms
{
  Check if the form is the current form
  Check if the form is the current form's child
  Check if the form is the current form's parent
  Check if a full path is specified
}

In general, I would doubt that form selection is really the issue, in that whatever form it selects, it would consistently select, so you wouldn't see records *sometimes* being attached to a different form.
  

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



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: using formfieldvalue to post to the correct fo
Reply #2 - Nov 10th, 2006 at 1:07am
Print Post Print Post  
Steve,

Even though your subform records are "Naturally" linked, that does not prevent you from including a "Key" element in them just like you would have if you were using "Relational" linking. This may help you to spot if there were any child records on the wrong parent.

Maybe you are already doing this, and that's how you're spotting them now. But, I thought I would just mention this, in case you didn't think of it yet.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: using formfieldvalue to post to the correct fo
Reply #3 - Nov 10th, 2006 at 1:23am
Print Post Print Post  
I agree completely with Carl.

If you ever need to ID the parent of the records in the children records, you may end up with many orphans because you cannot match the child with the parent.

Make sure evey parent has a unique ID, an element named RecordID works good, and copy the parent's unique value to the child with On Enter programming for the child.  An element named ParentID works good, The fields on both records should be ReadOnly, and can be made invisible unless some condition exists, like opening children records in their own database vs. looking at them in a subform.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: using formfieldvalue to post to the correct fo
Reply #4 - Nov 11th, 2006 at 5:07pm
Print Post Print Post  
Bob and Carl,

Yes, in addition to using Natural linking, I also have the forms tied together via Relational linking with matching key fields in the parent and child records. This 'backup' link is essential for correcting this issue I am having. 

The only way I have found to correct the issue is to export my data using the relational linking and then import them back into sesame using the natural linking.

We still prefer to use natural linking becuase relational linking is very slow when doing searches from the child records.

Thanks for the input.

Steve


  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: using formfieldvalue to post to the correct fo
Reply #5 - Nov 11th, 2006 at 5:21pm
Print Post Print Post  
Quote:
Yes, in addition to using Natural linking, I also have the forms tied together via Relational linking with matching key fields in the parent and child records.


It is not unlikely that this is the cause of the problem you are having.
  

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


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: using formfieldvalue to post to the correct fo
Reply #6 - Nov 11th, 2006 at 7:31pm
Print Post Print Post  
How can they be tied using BOTH Natural AND Relational? 
Is that really possible? 

I include the fields to "relate" parent and children records, but stay with Natural linking structure for the speed.  I stopped using Relational structures once I was aware of the speed differences.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: using formfieldvalue to post to the correct fo
Reply #7 - Nov 11th, 2006 at 7:45pm
Print Post Print Post  
Bob, I have 2 forms that are almost identical except one form uses Natural linking and the other uses relational. This way you get the best of both worlds.

Our users open the 'naturally linked' forms via command buttons, but when I find 'stray' or erroneous child records, I open the 'relationally linked' forms and do an export of the record.

Steve
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: using formfieldvalue to post to the correct fo
Reply #8 - Nov 11th, 2006 at 7:52pm
Print Post Print Post  
Bob_Hansen wrote on Nov 11th, 2006 at 7:31pm:
How can they be tied using BOTH Natural AND Relational? 
Is that really possible? 


You can have one parent natural link any record definition ("database") and as many as you want link relationally. It is possible because the natural link cause the parent to point to the first child, then each child points to the next child:

Parent's child ID: 12
   12: Child 1 --> Next: 17
   17: Child 2 --> Next: 32
   32: Child 3 --> Next: 91
   91: Child 4 --> Next: NULL

The example above shows a parent with four children. The last child's "next pointer" points at NULL, and ends the list.

With relational linking, the parent does not "point" at any children, it simply gathers those children that share the correct value in the key field by running through the list of all records that match the record type for its child. Because a relational parent does not concern itself with a child pointer, nor do relational children affect their "next pointers", both relational and natural linking can take place on forms at the same time.

But, it is a rarely needed capability that adds greatly to design complexity. Using this to check whether child records are in place, is likely to cause many more problems than it solves, especially in a highly automated application.

Quote:
I include the fields to "relate" parent and children records, but stay with Natural linking structure for the speed.  I stopped using Relational structures once I was aware of the speed differences.


That is a better idea for checking whether child records are landing where intended. It allows the user to reattach orphaned records easily. We have seen very little unintended orphaning lately. It seems to be reserved to a handful of users that are either running applications that were created before Sesame 1.0 (during Beta), or those that have been unlocked while running - or both.
  

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


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: using formfieldvalue to post to the correct fo
Reply #9 - Nov 11th, 2006 at 8:03pm
Print Post Print Post  
Mark,

Thanks for explaining (though I need to read it a few more times to comprehend).

It seems that my 'orphaned' or 'stray' child records are being found weeks later so recovering from a backup is not possible. Is there a way to spot when this issue is happening? Is there a line of programming that can be run during a mass update to confirm if the natural links are correctly in place?

Last week I noticed that about 12 parents were all missing their children, and one parent had 'adopted' all the missing children. Perhaps I should say 'kidnapped the children' Smiley

As funny as it sounds, this is an 'invoice' type of form and could cause some very embarrasing issues when billing a client. Whats the solution here?

Steve


  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: using formfieldvalue to post to the correct fo
Reply #10 - Nov 11th, 2006 at 8:20pm
Print Post Print Post  
As to finding the condition, yes. When leaving the record, count the children and place the count on the parent record. Then create a mass update that counts the children and compares the count to number held on the parent.

That would serve as a temporary bandaid. From your symptoms it sounds as though this application has a record pointer off in one or more of the children.
  

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


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: using formfieldvalue to post to the correct fo
Reply #11 - Nov 11th, 2006 at 8:29pm
Print Post Print Post  
Thanks Mark, I'll try your suggestion.

If one 'pointer' is off, is it possible to find where it is and simply erase and re-build that one record? Or do I need to export all the data, delete the entire database, then re-import the data in order to fix it?

Thanks,
Steve
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: using formfieldvalue to post to the correct fo
Reply #12 - Nov 11th, 2006 at 8:51pm
Print Post Print Post  
In Sesame 1.x.x, finding the records that have bad pointers is difficult for the end user. It usually caused by unlocking an active application and writing to it from a different memory image (running copy) of the same application. So the value appearing in the "bad" record appears perfectly legit becuase it came from a legit, though not current, copy of the same application. Imagine if you had two copies of MSWord running on different computers, both writing to the same file. Both "authors" would write perfect english, but because they are both writing to the same file, the document as a whole, wouldn't make sense.

To find the problem yourself, the best option would be a process of elimination. on a *copy* of your application, run a mass update that adds a fake subrecord to the subform in question and counts the before and after record counts and moves on to the next parent record. Then run a mass update that checks the same parents for the correct "after" counts. Then do the same with delete. Keep track of which parent records exhibit the problem. It is likely that it is not those parents that have the pointer off, but one of their children.

In Sesame 2.0, we have several import/export options including a XML format that closely matches the internal format. This can make finding and fixing such problems much much easier for end users. It has replaced our in house diagnostic tools, and was originally derived from them.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: using formfieldvalue to post to the correct fo
Reply #13 - Nov 11th, 2006 at 9:11pm
Print Post Print Post  
Steve,

When I've had to do this, I use a Mass Update that does an XLookupSourceListAll on the values that are supposed to match, counts the number of records found and compares that result to @FormResultSetTotal(Subform). If they don't match, something is wrong.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: using formfieldvalue to post to the correct fo
Reply #14 - Nov 11th, 2006 at 9:24pm
Print Post Print Post  
Mark and Erika,

Thanks for the suggestions. I'm trying Erikas suggestion now and I'll try Mark's when I have more time.

Thanks again for the help.

FYI - Ray has suggested I use more 'formcommit' commands to help avoid the issue in the future. Hopefully that will help.

Steve
  
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print