Normal Topic Loiter process (Read 1034 times)
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Loiter process
Jun 22nd, 2011 at 2:00pm
Print Post Print Post  
I need to send subform data to the parent record from a command button on the parent. Sometimes the FormResultSetCurrentPosition("Orders", nn) displays the wrong record.

The code below, without the Loiter(1000) command, does not work every time. I thought that maybe more time was necessary to allow FormResultSetCurrentPosition("Orders", nn) to get the current subform record number. So, I figured that a pause was needed for nn = @FormResultSetCurrentPosition("Orders") and Rnum = nn to run before executing the rest of the code.

When I put the Loiter command in, I was expecting Rnum = nn to populate Rnum on the parent first, then proceed with the rest of the code. What happens is that it pauses everything, then proceeds and again at times, FormResultSetCurrentPosition("Orders", nn) picks up the wrong subform record.

If I place the Programming guides Loiter example in the code it works as expected.
     WriteLn("Waiting")
     Loiter(1000)
     WriteLn("Done Waiting")

When I take away the WriteLn commands it again pauses everything and then proceeds with everything.

Is there a way that I can make sure that Rnum = nn executes before everything else?

Also, the pause I'm really hoping for that works is probably a quarter of a second, 250.

Thanks for any help.




Code
Select All
var vStr as string
var vStr2 as string
var vStr3 as string
var vStr4 as string
var nn as Int

Formcommit("Orders")

nn = @FormResultSetCurrentPosition("Orders")
Rnum = nn

Loiter(1000)

If @Mode() = 0 or @Mode() = 1
{
vStr = @FormFieldValue("Orders", "OrderDate", 0)
vStr2 = @FormFieldValue("Orders", "ccNumber", 0)
vStr3 = @FormFieldValue("Orders", "Amount", 0)
vStr4 = @FormFieldValue("Orders", "CCExpDate", 0)

SubOrderDate = vStr
Subcc# = vStr2
SubAmount = vStr3
SubExpireDate = vStr4

visibility(cmdSaveOrder,0)

Formcommit("")
}

FormResultSetCurrentPosition("Orders", nn)
 

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


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Loiter process
Reply #1 - Jun 22nd, 2011 at 2:12pm
Print Post Print Post  
I think much of your problem is order related. You want to pick up the number of the record you are interested in before the subform FormCommit (which can change the current record). Once you have that number, you should use it instead of the 0 that specifies "current record" (which may have changed with the FormCommit). Try something like this:

Code
Select All
var vStr as string
var vStr2 as string
var vStr3 as string
var vStr4 as string
var nn as Int

	nn = @FormResultSetCurrentPosition("Orders")
	Formcommit("Orders")
	Rnum = nn
	If @Mode() = 0 or @Mode() = 1
	{
		vStr = @FormFieldValue("Orders", "OrderDate", nn)
		vStr2 = @FormFieldValue("Orders", "ccNumber", nn)
		vStr3 = @FormFieldValue("Orders", "Amount", nn)
		vStr4 = @FormFieldValue("Orders", "CCExpDate", nn)

		SubOrderDate = vStr
		Subcc# = vStr2
		SubAmount = vStr3
		SubExpireDate = vStr4

		visibility(cmdSaveOrder,0)

		Formcommit("")
	}
	FormResultSetCurrentPosition("Orders", nn) 

  

- 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: Loiter process
Reply #2 - Jun 22nd, 2011 at 2:39pm
Print Post Print Post  
Thank you very much Erika, looks like it fixed it. Thanks for explaining the logic to me!

Concerning the Loiter command for future reference, if I place a Loiter(1000) after Rnum = nn, shouldn't I see Rnum populate, then experience the pause, then continue?

Thank you,

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


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Loiter process
Reply #3 - Jun 22nd, 2011 at 2:42pm
Print Post Print Post  
tcgeo wrote on Jun 22nd, 2011 at 2:39pm:
Thank you very much Erika, looks like it fixed it. Thanks for explaining the logic to me!

Glad to be of service.  Smiley

Quote:
Concerning the Loiter command for future reference, if I place a Loiter(1000) after Rnum = nn, shouldn't I see Rnum populate, then experience the pause, then continue?

Rnum will populate, but the screen may not redraw right away to show you that it repopulated. You can try using ForceRedraw to force the screen update, but, even then, the OS may not process the redraw right away.
  

- 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: Loiter process
Reply #4 - Jun 22nd, 2011 at 2:50pm
Print Post Print Post  
Never would have thought of that, thanks again and have a great day!
  
Back to top
IP Logged