Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula with boolean field!! 1

Status
Not open for further replies.

jodie

MIS
May 18, 2001
30
US
Hi,

i am doing a report where I have to get a count of all the cases of a sales rep by coverage.

For example:

Sales Rep: Joe Broker
Case 1
LF.............True
MD ............False
RX..............True

Case 2
LF.........True
MD.......True
RX........False

Case 3
LF.........False
MD........True
RX........False

Each case has multiple coverages(eg: LF, MD, RX) which may be True or False. I have to count:
-- the number of cases for which LF is true,
--the number of cases for which MD is True etc for this sales rep.
For the example above, LF is true for 2 cases, MD for 2 cases and RX for 1 case. The Coverage fields (i.e. LF, MD, RX are boolean fields in the database).

I have to do running totals or a manual count for these because I have eliminated certain records which are not being displayed by the report.

I am trying this formula.
whileprintingrecords;
numbervar counter;
if LF = False then
counter = counter + 1
else
counter

The problem is since I am using "False" it asks me to use a boolean after "then" also and does not recognize my formula. When I run my report I simply see a False for the value generated by my formula in the report.

please help!
thanks
 
You have a syntax error so cut and paste your exact formula into your next post.

If this IS your exact formula, then you need to put the field name in correctly, by double clicking that field from the field list. If it is truly a boolean, you don't have to say " = False" to create a condition, a boolean is automatically a condition by itself. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Also a syntax error here

counter = counter + 1

it should be

counter := counter + 1

Jim
 
Hi,

I guess the problem seemed to be with the initialization of the variable 'counter' in the group header and not in this formula...so after some fixing it started working. Thanks

I just ran into another problem. I am using a subreport in my main report. Is it possible to multiply a value(derived from a formula) in the main report with a value(from a formula) in the subreport?
I don't know if this is possible because in the main report I don't see the formula that I created in the subreport at all. Is there anyway I would be able to see and use the formula from the subreport in the main report

I can't seem to do both formulas in the same report and so I need to use a subreport.

Thanks
 
You need to declare a shared variable to move the value from Sub to Main. This would require 2 formulas, one in both sub and main. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Hi Ken,

I did a lot of searching in this forum but cannot exactly find how to declare and use shared variables. I was unable to find anything about shared variables in the Help section of Crystal report either.

The only thing I see repeated, time and again, in this forum is that article id c2007600 in Seagate Knowledge Base is supposed to help me.
How do I get to this article? I am really confused.

So, far I have done this to use shared variable. My subreport has the following 3 formulas.

1. reset counter (in GH1)
WhilePrintingRecords;
numbervar counter:=0;
ResetTotal ("counter")

2. counter (in Details section)
WhilePrintingRecords;
numbervar counter;
if {Proposal.Life Cov}=True
then
counter:=counter+1
else
counter

3. display counter(in GF1)
WhilePrintingRecords;
numbervar counter;
counter;

In my main report, I repeated the third formula("Display counter") in the GF1(b) section of the main report. The subreport lies in the GF1 (a) section of the main report

All I get for the formula (that i created agian in the main report) is a $0.00

Please help

Thanks
 
Just put the word "shared" in front of each "numberVar" statement. This is described in "variables syntax" in the help (v8), or under Variables, shared (v7).

You can find any article by putting the number into the "Ask Crystal" on the Crystal web site. I did and here is the link:

Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
I am using Version 6. Is there a way to share subreport data with the main report in Version 6?

Thanks
 
You will need to download the "Store" and "Fetch" functions from the Seagate web site. That was the older equivalent of shared variables. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Got it! I actually used the store and fetch functions and it works.

Thanks a lot Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top