Normal Topic XResultSetOpenForm ( ) with form with a subform (Read 1570 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
XResultSetOpenForm ( ) with form with a subform
Jun 20th, 2009 at 12:35pm
Print Post Print Post  
I use XResultSetOpenForm ( ) command to open up different forms to view the data related to the current record I am working on.  It is very fast especially if the form is already open, that is why I leave one form open in update mode. It works great. If the form is not open, it takes little time to open the form with the requested data.

If the form I am opening has subform, the first record will have proper subform display.  Leaving that form open and you use XResultSetOpenForm ( ) command with different record, the main record data will change and it will have proper data but the subform will retain data from the earlier record. How do I refresh the subform data? Do I have to use any additional codeing for it to work right?
  
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: XResultSetOpenForm ( ) with form with a subfor
Reply #1 - Jun 20th, 2009 at 1:51pm
Print Post Print Post  
To Clarify a little further, I have following code which is activated by command button.

Code
Select All
var vRSHandle as int
var vTotalRecords as int
var vLoop as int
var vVisitDate as String
var vStringDate as String
var vVisitString as String
var vRecordNumber as String


var vDate as String
var vDateString as String



var vSelectedDate as Date





	vRSHandle = @XResultSetSearch(@FN, "Physical", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!RecNumber=" + RecNumber)
	if(vRSHandle > -1)
	{
		vTotalRecords = @XResultSetTotal(vRSHandle)
		for vLoop = 1 to vTotalRecords
			XResultSetCurrentPosition(vRSHandle, vLoop)
			vVisitDate = @XResultSetValue(vRSHandle, "Date1")
			If vVisitString = "" then
				{
					vVisitString = vVisitDate
				}
				 Else
				{

					vVisitString = vVisitString + ";" + vVisitDate
				}
		next
			vVisitString = @SortStringArray (VVisitString, 0)
			vVisitString = @ReverseStringArray (vVisitString)
		XResultSetClose(vRSHandle)
	}


For vLoop = 1 to @CountStringArray(vVisitString)
	vDate = FormatDate (@AccessStringArray (vVisitString, vLoop))
	If vDateString = "" then
				{
					vDateString = vDate
				}
				 Else
				{

					vDateString = vDateString + ";" + vDate
				}
		next


//Writeln (vDateString)

PopupSelectPosition(4, @Xpos(ThisElement), @Ypos(ThisElement))
vSelectedDate = @PopupChoiceList(vDateString, "Select DATE")

If vSelectedDate <> "" Then
	{


		vRSHandle = @XResultSetSearch(@FN, "Physical", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!RecNumber="+ RecNumber, "!Date1="+ vSelectedDate)
			if(vRSHandle > -1)
				{
					WarningLevel(0)
					XResultSetOpenForm(vRSHandle, "Physical")
					WarningLevel(1)

					XResultSetClose(vRSHandle)
				}
	}

 



This is will display Popup with Dates patient was seen and selecting the date will display the physical exam form for the date. If you select one date, the first time the record with two subforms with medications display fine. But if you choose the different date (with the physical form with earlier record displayed, the main form data will change appropriately but the subform data remained unchanged that belonged to the earlier record. I hope this will make it a little clearer. Thanks.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XResultSetOpenForm ( ) with form with a subfor
Reply #2 - Jun 21st, 2009 at 4:28am
Print Post Print Post  
I built a test case using Countries.db and see what you are describing. I will see what I can do so that the first record resets its children for the next release.

Why are you using automation to achieve a result that is nearly identical to simply doing another search on the already open form? As a short term solution you might consider automating a normal search with a search spec, only allowing the XResultSetOpenForm from a blank search spec (instead of a populated record with subrecords), or only allowing the XResultSetOpenForm call on a second form for that purpose that opens a not-already-opened form.
  

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: XResultSetOpenForm ( ) with form with a subfor
Reply #3 - Jun 21st, 2009 at 4:36am
Print Post Print Post  
Thanks Mark, for looking into it.
  
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: XResultSetOpenForm ( ) with form with a subfor
Reply #4 - Sep 17th, 2009 at 4:24am
Print Post Print Post  
I am wondering if this problem is addressed and resolved in the ver. 2.5 ??
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: XResultSetOpenForm ( ) with form with a subfor
Reply #5 - Sep 17th, 2009 at 3:34pm
Print Post Print Post  
Bharat_Naik wrote on Sep 17th, 2009 at 4:24am:
I am wondering if this problem is addressed and resolved in the ver. 2.5 ??

Yes, this is fixed in 2.5.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged