Results 1 to 11 of 11
  1. #1
    Star Lounger
    Join Date
    Nov 2002
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    expression in control source (2000)

    Hi All, i have the following expression (=IIf([text121]<>-1 And [text136]=0,Count("[surname]"))) as the control source in a textbox of a report, but can't seem to get it to evaluate the number of records correctly. any suggestions would be greatly appreciated. thanks. Van

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: expression in control source (2000)

    Where is this text box, in the report footer or in the detail section?
    And what exactly do you want to count? Your expression looks inside out, but I'm not sure I can guess your intention.

  3. #3
    Star Lounger
    Join Date
    Nov 2002
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: expression in control source (2000)

    the textbox is in a group header. i want to count the number of records (from a qry) where one text box <>-1 and the other textbox =0.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: expression in control source (2000)

    Are the text boxes Text121 and Text136 bound to fields from the query (if so, which fields), or do they have a formula as control source?

  5. #5
    Star Lounger
    Join Date
    Nov 2002
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: expression in control source (2000)

    they are bound to fields in the query......entitled: pen and payment respectively.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: expression in control source (2000)

    Thanks. You *must* refer to the field names in your expression, not to the control names. Try this expression:

    =Sum(([Pen]<>-1)*([Payment]=0))

  7. #7
    Star Lounger
    Join Date
    Nov 2002
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: expression in control source (2000)

    thanks Hans. what i want to do is count the number of records where pen<>-1 AND payment=0. I don't know why my origianal expression didn't work b/c i have used a similiar one (see below) to count pen = -1 and pen<>-1.

    =IIf([text121]<>-1,Count("[surname]"))

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: expression in control source (2000)

    If your expression is in a group header, it will look at the value of Text121 for the first record in the group. If this value is not equal to -1, it will return the number of ALL records in the group. I doubt that is what you want. The expression I posted will count the number of records where pen<>-1 AND payment=0, as you asked.

  9. #9
    Star Lounger
    Join Date
    Nov 2002
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: expression in control source (2000)

    doesn't the * symbol in your expression mean multiply?

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: expression in control source (2000)

    Yes, it does. The "trick" of the expression is that True = -1 and False = 0. This is the result of multiplying:

    <table border=1><tr><td align=center>[b]

  11. #11
    Star Lounger
    Join Date
    Nov 2002
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: expression in control source (2000)

    thanks Hans. makes sense now. i'll work on it. regards, Van

Posting Permissions

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