Hot Topic (More than 10 Replies) @XResultSetSubSet (Read 1657 times)
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
@XResultSetSubSet
Dec 4th, 2010 at 10:06pm
Print Post Print Post  
I'm trying to post data to a subform that's located in the Agent Database, from a command button on a database called Login.

When I run this code a blank record and the words "New Task" are placed into the subform. When viewing the subform records from the subform you see the blank record and "New Task". But when I view the parent record "Carol", the "New task" entry does not show in the subform.

What step am I missing?

Thanks for the help.


Code
Select All
vRS = @XResultSetSearch(@FN, "Agent", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Name=Carol")      
     If vRS > -1
     {
           vCRS = @XResultSetSubSet(vRS, "SubForm")
           If vCRS > -1
           {
                 If "Task" <> ""
                {
				XResultSetCreateNewRecord(vCRS)
 				XResultSetValue(vCRS, "Task", "New Task")
                                XResultSetClose(vCRS)
                 }


				 

  
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @XResultSetSubSet
Reply #1 - Dec 5th, 2010 at 2:26pm
Print Post Print Post  
Just adding a record to a resultset you got with XResultSetSubset does not parent the new record. You need to call XResultSetReparent to actually parent your new subrecord.
  

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



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @XResultSetSubSet
Reply #2 - Dec 5th, 2010 at 2:37pm
Print Post Print Post  
Morning Erika,

Interestingly enough this has been working:
Code
Select All
var vRS as Int
var vCRS as Int


vRS = @XResultSetSearch(@FN, "agent", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Name=Carol")
If vRS > -1
{
	vCRS = @XResultSetSubSet(vRS, "Subform")
	If vCRS > -1
	{
//XResultSetCreateNewRecord(vCRS)
XResultSetValue(vCRS, "task", "New ttt4432")
//XResultSetReparent(vRS, "agent", vCRS)
	} 

  
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @XResultSetSubSet
Reply #3 - Dec 5th, 2010 at 2:39pm
Print Post Print Post  
oops, the last post was posted before i was ready to send.

I'm still not able to create a new record.

Can you help me with that?

  
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @XResultSetSubSet
Reply #4 - Dec 5th, 2010 at 2:40pm
Print Post Print Post  
And, I'll use reparent that's commented out too.
  
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @XResultSetSubSet
Reply #5 - Dec 5th, 2010 at 2:44pm
Print Post Print Post  
Ive tried this:

If Task <> " "
{
XResultSetCreateNewRecord(vCRS)
}

but doesn't make a difference...
  
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @XResultSetSubSet
Reply #6 - Dec 5th, 2010 at 3:01pm
Print Post Print Post  
You need XResutSetCreateNewRecord and XResultSetReparent. Create the new record, set the values you want in that record, then parent the new record to the correct parent record.
  

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



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @XResultSetSubSet
Reply #7 - Dec 5th, 2010 at 3:32pm
Print Post Print Post  
This works to set the value in the Task field to "New Task" in the subform as seen from the Agent form.

But when I remove the "comment" from XResultSetCreateNewRecord(vCRS) it does not create a new record and it fails setting the value also.

Just kinda lost....


Code
Select All
var vRS as Int
var vCRS as Int


vRS = @XResultSetSearch(@FN, "Agent", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Name=Carol")
If vRS > -1
{
	vCRS = @XResultSetSubSet(vRS, "Subform")
	If vCRS > -1
	{
	//XResultSetCreateNewRecord(vCRS)
	XResultSetValue(vCRS, "task", "New Task")
	XResultSetReparent(vRS, "Agent", vCRS)
	}

	XResultSetClose(vCRS)
}
 

  
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: @XResultSetSubSet
Reply #8 - Dec 6th, 2010 at 2:25pm
Print Post Print Post  
Hello tcgeo,

Try

Code
Select All
var vRS as Int
var vCRS as Int


vRS = @XResultSetSearch(@FN, "Agent", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Name=Carol")
If vRS > -1
{
	vCRS = @XResultSetSubSet(vRS, "Subform")
	If vCRS > -1
	{
		XResultSetCreateNewRecord(vCRS)
		XResultSetValue(vCRS, "task", "New Task")
		XResultSetReparent(vRS, "Subform", vCRS)
		XResultSetClose(vCRS)
	}

	XResultSetClose(vRS)
}
  



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @XResultSetSubSet
Reply #9 - Dec 6th, 2010 at 3:05pm
Print Post Print Post  
Thank you Ray,

So, my first wrong was not reparenting the subform?
Then, not closing the result sets correctly?

Also, does XResultSetCreateNewRecord only work when you also call XResultSetReparent?

And/or how else was I thinking incorrectly?

Thanks for your time and help.
  
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: @XResultSetSubSet
Reply #10 - Dec 6th, 2010 at 3:12pm
Print Post Print Post  
Hello,

The first problem was not reparenting the newly created record.
Second was reparenting the new record using the wrong field name.
Third was not closing all the result sets.

XResultSetCreateNewRecord will work in any result set but the newly added record will not be parented unless you call XResultSetParent.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @XResultSetSubSet
Reply #11 - Dec 6th, 2010 at 3:22pm
Print Post Print Post  
Very good, thank you.
  
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: @XResultSetSubSet
Reply #12 - Dec 6th, 2010 at 3:26pm
Print Post Print Post  
You are welcome.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged