Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) Needs help with xResultsetReparent ( ) command (Read 2510 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Needs help with xResultsetReparent ( ) command
Feb 29th, 2012 at 12:59pm
Print Post Print Post  
I have been using the code to make a document subrecord and then reparent it to the mainform. It works fine when I execute from the Layout in the different database but if it is initiated from the Layout of the same database where this subform belongs to, it does not add the subrecord in the form. The subrecord is made but it does not get reparented.  When I execute the same code from different database form, the earlier subrecords also shows up along with the new subrecord created.
Code
Select All
vChildRSID = @XResultSetSearch(@FN, "Index!Documents", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart==")

							If vChildRSID > -1 then
								{
									xResultSetCreateNewRecord (vChildRSID)
									xResultSetValue (vChildRSID, "RecNumber", vRecNumber)
									xResultSetValue (vChildRSID, "DateAdded", vDateAdded)
									xResultSetValue (vChildRSID, "Chart", vChart)
									xResultSetValue (vChildRSID, "Description", vDescription)
									xResultSetValue (vChildRSID, "View", vView)
									xResultSetValue (vChildRSID, "FileName", vFileName)
									xResultSetValue (vChildRSID, "Key", vKey)


									xResultSetClose (vChildRSID)

								}

							vParentRSID = @XResultSetSearch(@FN, "Index", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart=" + vChart)
								/*

								If @XResultSetLocked (vParentRSID) = 1 Then
									{
										@MSGBox ("Parent ResultSet is Locked", "The Document will not go to DocumentSubform", "Process it from Other Database")

									}
									Else If @XResultSetLocked (vParentRSID) = 0 Then
									{
										WriteLn ("Parent ResultSet is Not Locked")

									}
								*/



							If vParentRSID > -1 then
								{
									vRecordsFound = @XResultSetTotal (vParentRSID)
									If vRecordsFound = 1 then
										{
											vChildRSID = @XResultSetSearch(@FN, "Index!Documents", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart=" + vChart)

											If vChildRSID > -1 then
												{
													//WriteLN ("You were in ChildRSID")
													//WriteLN ("Total subrecords are " +   @Str (@xResultSetTotal (vChildRSID )) )
									                                xResultSetSort (vChildRSID, "DateAdded:1")
													xResultSetReparent (vParentRSID, "DocumentSubForm", vChildRSID)



													xResultSetClose (vChildRSID)
												}
										}
										Else if vRecordsFound = 0 then
										{
											WriteLN ("Chart " + vChart + " Does not exist in INDEX Database!!! Please Correct it" )
											vFailureIndicator = 1
										}
										Else if vRecordsFound > 1 then
										{

											WriteLN ("Chart " + vChart + " has Multiple Entries in INDEX Database!!! Please Correct it" )
											vFailureIndicator = 1
										}

									XResultSetClose (vParentRSID)


								}
							xResultSetClose (vChildRSID)       // for additional precaution - in case if it is not closed
							xResultSetClose (vParentRSID)		// for additional precaution - in case if it is not closed


 



I have tested to the extent that neither Parent nor Child resultsets gets locked up, still the xResultsetReparent ( ) command fails to work when executed from the database form where this subform is located.  The subrecord is made properly but does not show up in the subform.

I cannot use @FormfieldValue ( ) to fill up the subform record as the form that has the subform is usually not open and this code is initiated from the different form of the same database.

How can I make the code work when it comes to be executed from the same database form? Any suggestions?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Needs help with xResultsetReparent ( ) command
Reply #1 - Feb 29th, 2012 at 8:48pm
Print Post Print Post  
Hello Bharat,

If you un-comment the line that says
Code
Select All
WriteLN ("Total subrecords are " +   @Str (@xResultSetTotal (vChildRSID )) ) 


and run it from the documents database do you get the correct number of child records or is it missing the newly added one?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
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: Needs help with xResultsetReparent ( ) command
Reply #2 - Feb 29th, 2012 at 9:20pm
Print Post Print Post  
Ray, thanks a lot for looking into this.
It is missing the newly added one, if I do this from any form that belongs to the database to which the subform belongs. If the same code is executed from other database form, it will not miss the newly added one. The number that it shows as number of subform records will always be correct, meaning subrecord get formed but does not get parented properly if code is run from the subject database form.

Am I clear?
  
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: Needs help with xResultsetReparent ( ) command
Reply #3 - Feb 29th, 2012 at 9:31pm
Print Post Print Post  
Also, if I run the code from the form that has the Document subform and fill it up by creating @FormNewRecord ( ) and filling out the fields with Formfieldvalue ( ), it works well and adds the subform record as expected. Ofcourse, I had to modify notifyform (7) code that was interfering with the code earlier but Erika kindly pointed out the problem.
  
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: Needs help with xResultsetReparent ( ) command
Reply #4 - Feb 29th, 2012 at 9:43pm
Print Post Print Post  
To clarify even further, if I have any form belongs to the database to which the Documents subform is attached, open with the subject record (Does that lock the record?), and if I try to create and re-parent the subrecord even from other database forms, it will not reparent that subrecord and consequently, it will not show up in the subform.

However, the code to see if the parent handle (ParentRSID) is locked, it will show that it is not locked.  Embarrassed
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Needs help with xResultsetReparent ( ) command
Reply #5 - Mar 1st, 2012 at 2:16pm
Print Post Print Post  
Bharat_Naik wrote on Feb 29th, 2012 at 9:43pm:
However, the code to see if the parent handle (ParentRSID) is locked, it will show that it is not locked.  Embarrassed


It won't show as locked as it's open by the same client. If would show as locked if it was open by a different client.

Can you shoot an e-mail over to support@lantica.com with your sesame.ini file attached to it?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
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: Needs help with xResultsetReparent ( ) command
Reply #6 - Mar 3rd, 2012 at 8:16am
Print Post Print Post  
Code
Select All
var vRS as Int
var vCRS as Int


vRS = @XResultSetSearch(@FN, "Index", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart=" + Chart)
If vRS > -1
{
	vCRS = @XResultSetSubSet(vRS, "DocumentSubform")
	If vCRS > -1
	{
		XResultSetCreateNewRecord(vCRS)
		XResultSetValue(vCRS, "Description", "test record")
		XResultSetReparent(vRS, "DocumentSubform", vCRS)
		XResultSetClose(vCRS)
	}

	XResultSetClose(vRS)
}

 



Hi Ray,
I once again tested the above code placing in command button.  If I run the above code from any form (of course other than the form with the subform) that belongs to Parent database, the reparenting part will fail. The subrecord is made but just does not show up in the naturally linked subform.  But if the code is run from any form that belongs to database other than parent database, the subform record is made and also shows up in naturally linked subform.

I am afraid, the result of this test is consistent with my earlier experience.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Needs help with xResultsetReparent ( ) command
Reply #7 - Mar 5th, 2012 at 10:01pm
Print Post Print Post  
Bharat_Naik wrote on Mar 3rd, 2012 at 8:16am:
Hi Ray,
I once again tested the above code placing in command button.  If I run the above code from any form (of course other than the form with the subform) that belongs to Parent database, the reparenting part will fail. The subrecord is made but just does not show up in the naturally linked subform.  But if the code is run from any form that belongs to database other than parent database, the subform record is made and also shows up in naturally linked subform.

I am afraid, the result of this test is consistent with my earlier experience.


With the parent form open is the parent record that is getting the new child part of the retrieved result set, even if it is not the current record?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
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: Needs help with xResultsetReparent ( ) command
Reply #8 - Mar 5th, 2012 at 10:04pm
Print Post Print Post  
Any work around?  Could it be changed in the future?
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Needs help with xResultsetReparent ( ) command
Reply #9 - Mar 5th, 2012 at 10:46pm
Print Post Print Post  
Bharat_Naik wrote on Mar 5th, 2012 at 10:04pm:
Any work around?  Could it be changed in the future?

Ray's post is a question, Bharat, not a statement.
  

- Hammer
The plural of anecdote is not data.
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: Needs help with xResultsetReparent ( ) command
Reply #10 - Mar 5th, 2012 at 10:59pm
Print Post Print Post  
Thanks Erika for clarifying..  Parent form with the subform is not even open. New child record (subform record) is prepared in the resultset, that is to be reparented to the the form with subform so that it shows up in subform.

Am I clear?
  
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: Needs help with xResultsetReparent ( ) command
Reply #11 - Mar 5th, 2012 at 11:08pm
Print Post Print Post  
Yes, it is the Parent record but displayed in the different Layout (not the one with subform). And from that form the subrecord is created in the resultset using (command button) to be reparented to Parent record so that it shows up in the subform.
  
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: Needs help with xResultsetReparent ( ) command
Reply #12 - Mar 6th, 2012 at 6:06pm
Print Post Print Post  
So long as the parent record is open, through any layouts, the @xResultSetReparent ( ) command seems to fail. However, when test is run to see if the parent record is locked, the results shows the record is not locked. I am lost...  Embarrassed

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



Posts: 2530
Joined: Nov 22nd, 2002
Re: Needs help with xResultsetReparent ( ) command
Reply #13 - Mar 6th, 2012 at 6:42pm
Print Post Print Post  
Reparent requires that all of the child records in the result set be exclusively in that result set and no other. If some of the records are derived from an open subform, then some of the records are in another result set, the one for that subform. So if you are then adding to a set that already has some records, and these pre-existing records correspond to some on an open sub-form, some of your records are new and exclusive, but others are in a pre-existing second result set.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Needs help with xResultsetReparent ( ) command
Reply #14 - Mar 6th, 2012 at 6:55pm
Print Post Print Post  
Bharat_Naik wrote on Mar 6th, 2012 at 6:06pm:
So long as the parent record is open, through any layouts, the @xResultSetReparent ( ) command seems to fail. However, when test is run to see if the parent record is locked, the results shows the record is not locked. I am lost...  Embarrassed


Hello Bharat,

The records will not show as locked if they are open by the same client or if they are not the active record in another person's resultset. Mark is right that the XResultSetReparent command needs to have exclusive access to all the children records. It also needs exclusive access to the parent record, meaning that no other resultset can contain the parent or any of the child records(even if they are not the current record).

If you check @Error after the XResultSetReparent() call, it will return yes to indicate that it could not complete the reparenting procedure.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print