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.
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)