Consulting

Results 1 to 6 of 6

Thread: Solved: Formula produces wacky results

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Solved: Formula produces wacky results

    This formula averages text box values. After entering 2 numbers say 88 and 90 the average says it is something like 445.

    Anyone see anything wrong with this:

    [VBA]
    =IIf([BPSPF1Grade]>0,(nz([BPSPF1Grade])+nz([BPSPF2Grade])+nz([BPSPF3Grade])+nz([BPSPF4Grade])+nz([BPSPF5Grade])+nz([BPSPF6Grade])+nz([BPSPF7Grade])+nz([BPSPF8Grade])+nz([BPSPF9Grade])+nz([BPSPF10Grade])+nz([BPSPF11Grade])+nz([BPSPF12Grade])+nz([BPSPF13Grade])+nz([BPSPF14Grade])+nz([BPSPF15Grade])+nz([BPSPF16Grade])+nz([BPSPF17Grade])+nz([BPSPF18Grade])+nz([BPSPF19Grade])+nz([BPSPF20Grade])+nz([BPSPF21Grade])+nz([BPSPF22Grade])+nz([BPSPF23Grade])+nz([BPSPF24Grade])+nz([BPSPF25Grade])+nz([BPSPF26Grade])+nz([BPSPF27Grade])+nz([BPSPF28Grade])+nz([BPSPF29Grade])+nz([BPSPF30Grade]))/[PFNum],0)
    [/VBA]
    Peace of mind is found in some of the strangest places.

  2. #2
    VBAX Expert Imdabaum's Avatar
    Joined
    Jun 2006
    Posts
    652
    Location
    Does it make a difference if you add the valueifnull value as 0 instead of letting it default?
    Someday I'll understand everything...
    Even then...I'll still pretend I'm a beginner.

  3. #3
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    257
    Location
    I agree with Imdabaum. Try

    =IIf([BPSPF1Grade]>0,(nz([BPSPF1Grade],0)+nz([BPSPF2Grade],0)+nz([BPSPF3Grade],0)
    +nz([BPSPF4Grade],0)+nz([BPSPF5Grade],0)+nz([BPSPF6Grade],0)
    +nz([BPSPF7Grade],0)+nz([BPSPF8Grade],0)+nz([BPSPF9Grade],0)
    +nz([BPSPF10Grade],0)+nz([BPSPF11Grade],0)+nz([BPSPF12Grade],0)
    +nz([BPSPF13Grade],0)+nz([BPSPF14Grade],0)+nz([BPSPF15Grade],0)
    +nz([BPSPF16Grade],0)+nz([BPSPF17Grade],0)+nz([BPSPF18Grade],0)
    +nz([BPSPF19Grade],0)+nz([BPSPF20Grade],0)+nz([BPSPF21Grade],0)
    +nz([BPSPF22Grade],0)+nz([BPSPF23Grade],0)+nz([BPSPF24Grade],0)
    +nz([BPSPF25Grade],0)+nz([BPSPF26Grade],0)+nz([BPSPF27Grade],0)
    +nz([BPSPF28Grade],0)+nz([BPSPF29Grade],0)+nz([BPSPF30Grade],0))/[PFNum],0)

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    The other thing to check is that your fields are set to Number and not text as it could be concatenating text and then doing the division, in which case you will need to use VAL() in your caclulation.
    In fact that is the problem.
    9980/2 = 445.

  5. #5
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Thats exactly right OPB. That is the problem they are set to text. Now where do you use val at?
    Peace of mind is found in some of the strangest places.

  6. #6
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    I figured it out. OBP was right. Changing the fields from Test to Number was thet solution. Solved.
    Peace of mind is found in some of the strangest places.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •