|
-
Jul 24th, 2008, 09:10 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Boolean sum? in CRX
I have a boolean field in my access database. I am trying to create a function that returns true when that boolean field = true. There are multiple records though. So I would need something that does this (in vb6 pseudocode)
Assume that all records will be true (set the flag to true)
For each record (until EOF=true):
Does the field = false?
If so, then set the flag to false
Go to the next record and test again
Anyone have any ideas? I think I might be able to do something like this with a running total field. I don't need to enter to code as I jsut showed, but I just put it there for conceptual purposes.
-
Jul 24th, 2008, 10:15 AM
#2
Frenzied Member
Re: Boolean sum? in CRX
How about a formula field?
If {YourField} = False
"False"
Else
"True"
Syntax might be alittle off.
-
Jul 24th, 2008, 12:31 PM
#3
Thread Starter
Fanatic Member
Re: Boolean sum? in CRX
That might work but then how do I get it to check for all records? I need it to check all records and set a flag to true if a certain boolean field =true at all in any of those records.
-
Jul 24th, 2008, 12:56 PM
#4
Frenzied Member
Re: Boolean sum? in CRX
put the formula field in the details section.
-
Jul 24th, 2008, 01:54 PM
#5
Re: Boolean sum? in CRX
Insert a formula and place at detail section
Code:
If {Table.Field}=True then 1 else 0
Then insert a Summary for that formula field and place at end of report (or group)
At end of report (or group) ask for the Summary field, If it is greater than 0 then at less one record was true
-
Jul 24th, 2008, 02:55 PM
#6
Thread Starter
Fanatic Member
Re: Boolean sum? in CRX
what does it set to one? Is there a variable name I'm checking? I see that your formula returns one... where does it reutrn the one to?
-
Jul 25th, 2008, 08:57 AM
#7
Thread Starter
Fanatic Member
Re: Boolean sum? in CRX
i put this in my details:
vb Code:
global numbervar vp_HMCount_int; if {Packages.Hazardous?}=true then ( vp_HMCount_int=vp_HMCount_int+1 )
The when I try to reference vp_HMCount_int in a suppress formula it says "A number, boolean value......is required here." Basically saying it can't identify the variable. How do I make the variable global?
-
Jul 25th, 2008, 11:31 AM
#8
Re: Boolean sum? in CRX
A Global variable must have the same declaration in every formula that uses it.
-
Jul 25th, 2008, 03:43 PM
#9
Thread Starter
Fanatic Member
Re: Boolean sum? in CRX
OK. Managed to get access to the variable working, but that's about it. I made the function above that incremenets a global counter and I made it return the counter for debug purposes. I put the formula field in the details section. I made a boolean formula field that returns true if vp_HMCount_int > 0. The boolean formula keeps returning false and the counter stays at zero. Is there something I'm doing wrong? Do I need to make the variable static somehow?
-
Jul 28th, 2008, 12:03 PM
#10
Re: Boolean sum? in CRX
To set a variable you need to use :=, eg
vp_HMCount_int := vp_HMCount_int+1
In your "boolean formula", try the EvaluateAfter function. something like
global numbervar vp_HMCount_int;
EvaluateAfter ({@Name of other formula});
vp_HMCount_int > 0
-
Jul 28th, 2008, 12:27 PM
#11
Thread Starter
Fanatic Member
Re: Boolean sum? in CRX
awesome. thanks. it works now. I'm fairly new to crystal, so I ended up forgetting the colon.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|