-
Formulas always 0
Hi everybody,
I have a report holding about 25 formulas layout as table, values sent by VB code. One of them (rest are OK) always display zero, although it shouldn't and VB debugger told me it's not. As rest of formulas, this formula is set as:
1. 0 as formula text default. (If I change to blank, it's always blank, by the way.)
2. Under formulas field: Suppress if zero is NOT checked; Decimals = 1; Rounding = 1; Negative = None; Leading Zero is checked, and the sample show as 55556.
I have tried to move this formula around, rename it, delete it then recreate it. No matter what it is called and where it is, it just display 0. I don't think I have any wrong name problem since I have play this around for a while and there is no naming error come from Crystal.
Appreciate if anybody can tell me how to deal with this. Thanks.
-
Re: Formulas always 0
Could you post your source code? I don't understand how vb is interacting with that formula/string/thing.
-
Re: Formulas always 0
Post some code that could be better.
If you want me to hazzard a guess: i would do it like this: Since you say that the Debug mode says the value ( i assume after calulations) is non-zero, the only step that should be checked is when/where it is being set to the textbox/label caption. In some situations the names of similar txtboxes would be simlar, so could even be a simple typing error, by which some other text/label is being changed. Check on those lines, if you think the formula & its decifering & cals are correct.!
RK
-
Re: Formulas always 0
I am sorry. Here is fragment of code. To save space I simply them.
' this function access db, do the calculation and populate Crystal
' formulas, then produce the report using the sent Crystal report object
private Sub DoReport(rpt as Object)
' set datafile path so Crystal can access the db directly
rpt.DataFiles(0) = "c:\...\db.mdb"
' set formulas with values (here called value1, value2...) after
' calculation. These formulas are actually strings with their
' layout setup during design time of Crystal. When I do the report
' by using the sent Crystal rpt object, the report will use sent
' values via formulas and populate these strings on the report
' I am sure the formulas name (FormulaVal1, FormulaVal2...)
' are exactly the same as those on Crystal report
rpt.Formulas(0) = "Value1= " + DblQuotes(CStr(value1))
rpt.Formulas(1) = "Value2= " + DblQuotes(CStr(value2))
... ...
' do the report
rpt.Action = 1
' clear report formulas
...
End Sub
The funny things is that, like I said before, one of these formulas will not display the value I sent. Instead it displays a zero. When debug through the code above and I am sure:
1. the formulas name is right;
2. formulas index not overlapping or missing;
3. rpt.Formulas(n) is the value I sent when I watch it from immediate debug window;
Here is my clue of the problem. Would be great if anybody give me a clue why. Thanks a lot.