form line control

Hi folks…

I have a form which I’ve added 3 variable columns
unfortunately I’m having trouble with the way in which the fields are displaying.

I think its a refresh problem, however I’ve tried CurrForm.Update

Problem.

When the form opens and I select a line this is fine, however when I move/scroll
to the next line, the figures double up (its like watching the matrix film)!

My code is on the Form - aftergetrecord.
again I have also tried CurrForm.Update on variable field - textbox onActivate & deactivate

ver 3.7 run Nav execute.

Regards

Paddy

Are you resetting the variables to zero every time before you do the calculation?

Hi Matt,

I have the variable reset on the Form - open form

Perhaps you could paste your code from the OnAfterGetRecord trigger?

Form - OnOpenForm()
RESET;

//PAD007>>
GDecValueDown := 0;
GDecValueUp := 0;
GRecGiftCardsUp.RESET;
GRecGiftCardsDown.RESET;
GRecGiftCardsUsed.RESET;
GRecGiftCardsUp.DELETEALL;
GRecGiftCardsDown.DELETEALL;
GRecGiftCardsUsed.DELETEALL;
//PAD007<<

Form - OnAfterGetRecord()
SetDateFilter;
WITH Store DO BEGIN
CALCFIELDS(“No. of Sales Transactions”,“Net Turnover”,“Net Cost”,“No. of Items Sold”,“Gross Turnover”);
IF “No. of Sales Transactions” <> 0 THEN BEGIN
Average := ROUND((“Net Turnover” / “No. of Sales Transactions”),0.01);
AveItemsSold := ROUND((“No. of Items Sold” / “No. of Sales Transactions”),0.01)
END ELSE BEGIN
Average := 0;
AveItemsSold := 0;
END;
TransNum := “No. of Sales Transactions”;
SalesAmt := “Net Turnover”;
CostAmt := “Net Cost”;
ItemsSold := “No. of Items Sold”;
//Doc RN???
GrossAmt := “Gross Turnover”;

//PAD007>>
Tender := ‘20’;

TransIncomeExpEntry.RESET;
TransIncomeExpEntry.SETCURRENTKEY(“No.”,“Transaction Status”,Date,“Store No.”,Time);
TransIncomeExpEntry.SETRANGE(“No.”,Tender);
TransIncomeExpEntry.SETRANGE(“Store No.”,Store.“No.”);
TransIncomeExpEntry.SETFILTER(Date,Store.GETFILTER(“Date Filter”));
TransIncomeExpEntry.SETFILTER(Time,Store.GETFILTER(“Time Filter”));
TransIncomeExpEntry.SETFILTER(“Transaction Status”,’%1|%2’
,TransIncomeExpEntry.“Transaction Status”::" "
,TransIncomeExpEntry.“Transaction Status”::Posted);
IF TransIncomeExpEntry.FINDSET THEN
BEGIN
REPEAT
IF (TransIncomeExpEntry.Amount > 0) {Redeemed} THEN BEGIN
GRecGiftCardsUp.“No.” := TransIncomeExpEntry.“Card or Account”;
GRecGiftCardsUsed.“No.” := TransIncomeExpEntry.“Card or Account”;
IF GRecGiftCardsUsed.INSERT THEN;
IF GRecGiftCardsDown.INSERT THEN;
TransSaleEntry.SETRANGE(“Store No.”,TransIncomeExpEntry.“Store No.”);
TransSaleEntry.SETRANGE(“POS Terminal No.”,TransIncomeExpEntry.“POS Terminal No.”);
TransSaleEntry.SETRANGE(“Transaction No.”,TransIncomeExpEntry.“Transaction No.”);
IF TransSaleEntry.FINDSET THEN
BEGIN
REPEAT
GDecValueDown += ABS (TransSaleEntry.Price)
UNTIL TransSaleEntry.NEXT = 0
END;
END
ELSE
GDecValueDown := 0;

IF (TransIncomeExpEntry.Amount < 0) {Value Added to Card} THEN BEGIN
GRecGiftCardsUp.“No.” := TransIncomeExpEntry.“Card or Account”;
GRecGiftCardsUsed.“No.” := TransIncomeExpEntry.“Card or Account”;
IF GRecGiftCardsUsed.INSERT THEN;
IF GRecGiftCardsUp.INSERT THEN;
TransSaleEntry.SETRANGE(“Store No.”,TransIncomeExpEntry.“Store No.”);
TransSaleEntry.SETRANGE(“POS Terminal No.”,TransIncomeExpEntry.“POS Terminal No.”);
TransSaleEntry.SETRANGE(“Transaction No.”,TransIncomeExpEntry.“Transaction No.”);
IF TransSaleEntry.FINDSET THEN
BEGIN
REPEAT
GDecValueUp += ABS (TransSaleEntry.Price)
UNTIL TransSaleEntry.NEXT = 0
END;
END
ELSE
GDecValueUp := 0;
UNTIL TransIncomeExpEntry.NEXT = 0;
END;
//PAD007<<

I’ve added an IF ISEMPTY statment outside of the FINDSET…

seems to have stopped the duplication of values

I’m guessing GDecValueDown and GDecValueUp are the values you’re displaying. Think about where you need to reset these values.

You’re on one record and it calculates the value. Now it finds another record, but doesn’t reset the value to zero before calculating it. So it will add to the previous value. It only resets them one time, when the form is opened, and at that point they are already zero anyway.

I see you have the resets in the ELSE clauses, but nowhere else. Wouldn’t you want to start with a zero value before you loop through the TransSaleEntry records as well?

Hi Matt…

Your correct GDecValueDown & GDecValueUp are my Values.

I did try reseting before the TransSaleEntry Loop - but this only reported the last record value? It wasn’t adding the value of previous find value…

copy of how it was…

IF (TransIncomeExpEntry.Amount < 0) {Value Added to Card} THEN BEGIN
GRecGiftCardsUp.“No.” := TransIncomeExpEntry.“Card or Account”;
GRecGiftCardsUsed.“No.” := TransIncomeExpEntry.“Card or Account”;
IF GRecGiftCardsUsed.INSERT THEN;
IF GRecGiftCardsUp.INSERT THEN;
GDecValueUp := 0;
TransSaleEntry.SETRANGE(“Store No.”,TransIncomeExpEntry.“Store No.”);
TransSaleEntry.SETRANGE(“POS Terminal No.”,TransIncomeExpEntry.“POS Terminal No.”);
TransSaleEntry.SETRANGE(“Transaction No.”,TransIncomeExpEntry.“Transaction No.”);
IF TransSaleEntry.FINDSET THEN
BEGIN
REPEAT
GDecValueUp += ABS (TransSaleEntry.Price)
UNTIL TransSaleEntry.NEXT = 0
END;