i am creating a new report from a table calle “unit” which i have created my self. i need a field called “unit code” from this table to the report and i also need to total the number of vendors from the “vendor” table with same unit code(field created by myself). i have done this and the total number of vendors appears for each unit code. but in this report i need to sum those vendors only whose field called “active/ceased” has option “active” which i have created in the vendor table. when i wrote if statement in my report the total comes 0… need help.!!
Can you show us the code?
TotalReg := 0;
GrandTotal := 0;
Vendor.RESET;
Vendor.SETRANGE(“Unit Code”, “Unit Code”);
IF Vendor.“Active/Ceased” = Vendor.“Active/Ceased”::Active THEN BEGIN
IF Vendor.“Grant End Date” > WORKDATE THEN BEGIN
countret(COUNT);
END;
END;
when function is called:
CLEAR(count);
IF Vendor.FINDFIRST THEN BEGIN
REPEAT
count := count + 1;
UNTIL Vendor.NEXT = 0;
TotalReg := TotalReg + count;
END;
I am not sure why are using function…but you can simply write
TotalReg := 0;
GrandTotal := 0;
Vendor.RESET;
Vendor.SETRANGE(“Unit Code”, “Unit Code”);
IF Vendor.FINDFIRST THEN BEGIN
IF Vendor.“Active/Ceased” = Vendor.“Active/Ceased”::Active THEN BEGIN
IF Vendor.“Grant End Date” > WORKDATE THEN BEGIN
VendCount := VendCount + 1;
END;
END;
END;
Count is the reserved word so please use vendCount
thank you but i didn’t solve my problem…!!
thank you but it didnt solve my problem
sorry…
you have to repeat the loop
IF Vendor.FINDFIRST THEN
REPEAT
IF Vendor.“Active/Ceased” = Vendor.“Active/Ceased”::Active THEN BEGIN
IF Vendor.“Grant End Date” > WORKDATE THEN BEGIN
VendCount := VendCount + 1;
END;
END;
UNTIL Vendor.Next = 0;