Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Invalid Formula Post Reply Post New Topic
Author Message
JuliaRomero
Newbie
Newbie


Joined: 01 Jun 2009
Location: Spain
Online Status: Offline
Posts: 4
Quote JuliaRomero Replybullet Topic: Invalid Formula
     Posted: 22 Sep 2009 at 6:26am
Hello!! I have a formula in Crystal Reports 2008 where I declare some variables. The formula is:

NumberVar CarrierVATPercent;
NumberVar CarrierVATAmount;
NumberVar VATAmount;

VATAmount: = (Sum ((SSAA_IINN_00000200_A.TaxAmount), (SSAA_IINN_00000200_A.TaxValue)));
if (CarrierVATPercent = (SSAA_IINN_00000200_A.TaxValue)) then VATAmount: = VATAmount + CarrierVATAmount;

With this code I get the following error:

Error in the formula. This field name 'NumberVar CarrierVATPercent' is unknown.

Thanks for your help!!!
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 22 Sep 2009 at 9:14am
It seems to me you have not set the value for CarrierVATPercent, so when you are doing the comparision in the IF statement there is not a value to compare to other side of the = statement. This probably why the variable is reported as unknown.
 
Hope this helps
 
Regards,
 
John W.
IP IP Logged
JuliaRomero
Newbie
Newbie


Joined: 01 Jun 2009
Location: Spain
Online Status: Offline
Posts: 4
Quote JuliaRomero Replybullet Posted: 23 Sep 2009 at 1:44am
You gave me very good track. Apart from the initialization of variables I have discovered more things. We are feeding the report through code with a DataSet. If a report has a subreport with the same table in the subreport and there is a formula that declares a variable and then a field asigned to that variable it fails. The solution is to add the formula field in the main report. Do you know if Crystal even if you have a table that is used with two different aliases feeds with the same datatable?

Thanks for all, regards.
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 23 Sep 2009 at 12:37pm
I am not sure I fully understand the question. If you are loading from a dataset, where is that dataset created? When I think of datasets I think of .Net datasets which could be my problems.
 
If you want to pass values between a subreport and main report the answer lies in setting the scope of the variable to shared. For example, keep in mind how the main report is generated first and the subreports in subsequent passes.
 
You can use these methods to control passing information to the subreport selection formulas as well. 
 
Formula MainReport
shared numbervar x;
 
 
Formula subreport
shared numbervar x;
 
 
I hope something here will help.
 
Regards,
 
John W.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum