Am trying to generate records in a table using xbasic. One of the fields, bank_bal, is a calculated field via field rules. The calculation is based on the previous value in that field plus the value in an another field, open_bal, which is only used for the first record in the table. When the script generates the records, the first record is computed correctly. Then it alternates between 0.00 and the correct value. So record one is correct, say 10,000.00, the next is 0.00, the next is 10,000.00, etc.
Here's a partial of the script:
Have attached a bare bones of the script/form. The table is currently empty. Just open the form aplan and press the "Run Script" button to load the records into the table. When I debug, at the first tbl.enter_end() the calculation is done and tbl.bank_bal = 10,000.00. On tbl.enter_begin(), it resets to zero, then at tbl.enter_end(), it remains at zero and on the next tbl.enter_begin() it resets to 10,000.00 and on down the script, alternating this way.
Would like to know why it behaves this way.
Thanks.
Ernie
Here's a partial of the script:
Code:
dim tbl as p dim bal as n tbl = table.current() bal = 10000.00 ' debug(1) tbl.enter_begin() tbl.aplan_id = 1 tbl.open_bal = bal tbl.ap_sortno = 1 tbl.ap_month = "January" tbl.ap_year = var->glo_Year tbl.bank_id = 1 tbl.enter_end() [COLOR="Red"]<< tbl.bank_bal=10,000.00[/COLOR] tbl.enter_begin() [COLOR="Red"]<< tb.bank_bal=0.00[/COLOR] tbl.ap_sortno = 2 tbl.ap_month = "February" tbl.ap_year = var->glo_Year tbl.bank_id = 1 tbl.open_bal = 0 tbl.enter_end() [COLOR="Red"]<< tbl.bank_bal=0.00[/COLOR] tbl.enter_begin() [COLOR="Red"]<< tbl.bank_bal=10,000.00[/COLOR] tbl.ap_sortno = 3 tbl.ap_month = "March" tbl.ap_year = var->glo_Year tbl.bank_id = 1 tbl.open_bal = 0 tbl.enter_end() [COLOR="Red"]<< tbl.bank_bal=10,000.00[/COLOR] tbl.enter_begin() [COLOR="Red"]<< tb.bank_bal=0.00[/COLOR] tbl.ap_sortno = 4 tbl.ap_month = "April" tbl.ap_year = var->glo_Year tbl.bank_id = 1 tbl.open_bal = 0 tbl.enter_end()
Would like to know why it behaves this way.
Thanks.
Ernie
Comment