Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Apr 2008
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am tryng to run an OpenReport command with a where statement that selects numbers less than 5 in a field. I can not get the syntax correct.

    This is my latest effort;

    DoCmd.OpenReport "rptHeightWeightPercentiles", acViewPreview, , "[Percentile] <5"

    Can anyone help with the correct <5 code to make this work.

    Thanks.

    Paul

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts
    Quote Originally Posted by pbien View Post
    I am tryng to run an OpenReport command with a where statement that selects numbers less than 5 in a field. I can not get the syntax correct.

    This is my latest effort;

    DoCmd.OpenReport "rptHeightWeightPercentiles", acViewPreview, , "[Percentile] <5"

    Can anyone help with the correct <5 code to make this work.

    Thanks.

    Paul
    [Percentile] has to be a field in the underlying SQL statement for the report. And it needs to be a number (not a text string) to work as you've got it written.

    Are you getting an error (if so, what is it), or just no data?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    2 Star Lounger
    Join Date
    Apr 2008
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry it took so long to write back.

    The field is a number field. I do not get an error message. I get all the data files, not jus the ones less than 5.

    Paul

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    I can't see anything wrong with the code you are using. I would expect it to work.

    Can you post a sample db that we could look at?
    Regards
    John



  5. #5
    2 Star Lounger
    Join Date
    Apr 2008
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts
    While preparing the sample database I found my problem. Stupid mistake.

    Now I have a related code question. In my attached sample one of the choices is to print all records that are between 85 and 95.

    = to or > 85 and = to < 95

    or you could say > 84 and < 96

    Not sure how to code that.

    Can you help.

    Thanks.

    Paul
    Attached Files Attached Files

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    There are two options for the between 85 and 95 case.

    One (not surprisingly) is: "[Percentile] between 85 and 95"

    The alternative is : "([Percentile] >= 85) and ([percentile] <=95)"
    Regards
    John



  7. #7
    2 Star Lounger
    Join Date
    Apr 2008
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks. That works.

    Didn't think it would be that easy. I kept trying to make it more difficult.

    Paul

Posting Permissions

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