Topic: Working with variants triggering Access Violation
I am getting the following error when a grid view displays a value that was a variant.
Access violation at address 009C713F in module 'Manage.exe'. Read of address 00000001.
Here is the code for saving the variant (which works properly):
Procedure CalculatePercentageTotals;
Var
NetAmount, TotalSales, TheResult : Variant;
Begin
If (Sales_Sheet_Add.fld_Net.value <> 0) AND (Sales_Sheet_Add.fld_TotalSales.Value <> 0)then
begin
NetAmount := Sales_Sheet_Add.fld_Net.value;
TotalSales := Sales_Sheet_Add.fld_TotalSales.value;
TheResult := (NetAmount / TotalSales);
Sales_Sheet_Add.fld_Percentage.text := TheResult.AsString
end
End;
The above code works properly, after closing down the form and loading it again.
The values are correct, but it triggers the above error when it opens for the first time.
After opening it a second time, it all works properly and the percentage is displayed.
Any ideas Dmitry?
Thanks!
Mike