Hi Paul,
This.destroy instead of thisform.de.closetables would correct the problem I see. But I couldn't get yet why only return .f. there is not sufficient. With default DE values tables would close. Anyway I want to point out something else, as I could see you don't need something from form up to that return .f. so why not do it in a prg or form (whereever do form called) and don't call it (instead of return .f.). And I would change the scan..endscan code to :
scan
insert into cpayment ;
(cpay_pk, cpay_schdate, cpay_lessdate, cpay_paydate, ;
cpay_flag, cpay_paid, cpay_instamt, cpay_update, cpay_updInstBal) ;
values ;
(payment.pay_pk, payment.pay_schdate, payment.pay_lessdate, ;
payment.pay_paydate, .f., payment.pay_amt, payment.pay_instamt, ;
"", .f.)
endscan
Cetin
>Cetin,
>Here is the init code:
>*******************************************
>zap in cpayment
>
>this.txtToday.value = date()
>
>set procedure to lsfuncs additive
> this.txtpay_acct.value = findacct()
> this.txtpay_sub.value = findsub(this.txtpay_acct.value)
>release procedure lsfuncs
>
>if this.txtpay_acct.value = 0 or this.txtpay_sub.value = 0 then
> this.grdnav.recordsource = space(0)
> use in cpayment
> thisform.dataenvironment.closetables
> return .f.
>endif
>
>if this.txtpay_acct.value > 0 and this.txtpay_sub.value > 0 then
> select student
> set order to stu_acct
> seek (str(this.txtpay_acct.value)+str(this.txtpay_sub.value))
> this.txtpay_student.value = student.stu_student
>
> select payment
> set order to pay_acct
> set filter to pay_acct = student.stu_acct and pay_sub = student.stu_sub
>
> scan
> select cpayment
> append blank
> replace cpay_pk with payment.pay_pk
> replace cpay_schdate with payment.pay_schdate
> replace cpay_lessdate with payment.pay_lessdate
> replace cpay_paydate with payment.pay_paydate
> replace cpay_flag with .f.
> replace cpay_paid with payment.pay_amt
> replace cpay_instamt with payment.pay_instamt
> replace cpay_update with " "
> replace cpay_updInstBal with .f.
> select payment
> endscan
>
> select cpayment
> set order to cpay_dte descending
>endif
>
>thisform.grdnav.setfocus()
>*********************************************************
>I'm not sure what you mean by form.de settings unless you mean DataSession is set to "2-Private data session"
>
>>Paul,
>>Couldn't create it happen. Could you pls paste form.de settings + init code.
>>Cetin
>>>Sorry to be such a pain...
>>>
>>>I now check to see if findacct returned a 0. if so:
>>>
>>>if this.txtAcct.value = 0 then
>>> use in cpayment
>>> thisform.dataenvironment.closetables
>>> return .f.
>>>endif
>>>
>>>Everything works except that the datasession still exists in the DataSession window. I can't figure out how to close or release this datasession.
>>Snip...