Results 1 to 11 of 11

Thread: [RESOLVED] Boolean sum? in CRX

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2007
    Location
    Middletown, CT
    Posts
    948

    Resolved [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.

  2. #2
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Boolean sum? in CRX

    How about a formula field?

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


    Syntax might be alittle off.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2007
    Location
    Middletown, CT
    Posts
    948

    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.

  4. #4
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Boolean sum? in CRX

    put the formula field in the details section.

  5. #5
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    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

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2007
    Location
    Middletown, CT
    Posts
    948

    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?

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2007
    Location
    Middletown, CT
    Posts
    948

    Re: Boolean sum? in CRX

    i put this in my details:
    vb Code:
    1. global numbervar vp_HMCount_int;
    2.  
    3. if {Packages.Hazardous?}=true then (
    4.     vp_HMCount_int=vp_HMCount_int+1
    5. )

    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?

  8. #8
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Boolean sum? in CRX

    A Global variable must have the same declaration in every formula that uses it.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2007
    Location
    Middletown, CT
    Posts
    948

    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?

  10. #10
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    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

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2007
    Location
    Middletown, CT
    Posts
    948

    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
  •  



Click Here to Expand Forum to Full Width