PDA

Click to See Complete Forum and Search --> : [RESOLVED] Boolean sum? in CRX


drag0n_45
Jul 24th, 2008, 09:10 AM
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.

Besoup
Jul 24th, 2008, 10:15 AM
How about a formula field?

If {YourField} = False
"False"
Else
"True"


Syntax might be alittle off.

drag0n_45
Jul 24th, 2008, 12:31 PM
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.

Besoup
Jul 24th, 2008, 12:56 PM
put the formula field in the details section.

jggtz
Jul 24th, 2008, 01:54 PM
Insert a formula and place at detail section

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

drag0n_45
Jul 24th, 2008, 02:55 PM
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?

drag0n_45
Jul 25th, 2008, 08:57 AM
i put this in my details:

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?

brucevde
Jul 25th, 2008, 11:31 AM
A Global variable must have the same declaration in every formula that uses it.

drag0n_45
Jul 25th, 2008, 03:43 PM
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?

brucevde
Jul 28th, 2008, 12:03 PM
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

drag0n_45
Jul 28th, 2008, 12:27 PM
awesome. thanks. it works now. I'm fairly new to crystal, so I ended up forgetting the colon.