Results 1 to 9 of 9
  1. #1
    New Lounger
    Join Date
    Apr 2002
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If...then (2000-2002)

    How do I make Access put in information depending on the criteria? For instance, if someone scores a 90 to 100 I want to put an "A" in the box, if 80 to 89 a "B" in the box and so on.

  2. #2
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: If...then (2000-2002)

    ... I am assuming that you do not plan on coding in Visual Basic. Within the Field of the query, you could do a multi level If then statement such as below:

    IIf([FIELD1]>=90,"A",IIf([FIELD1]>=80,"B",IIf([FIELD1]>=70,"C","D")))
    Regards,

    Gary
    (It's been a while!)

  3. #3
    2 Star Lounger
    Join Date
    Dec 2000
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If...then (2000-2002)

    You could use the Switch function:

    : Switch([score] Between 90 And 100,"A",[score] Between 80 And 89,"B",---and the rest---)

  4. #4
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Richland, Washington, USA
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If...then (2000-2002)

    Okay, let see how many ways there are in Access to solve this problem...

    You could use something like:

    <font face="Georgia">Choose(11 - Int([score] / 10), "A", "A", "B", "C", "D", "F", "F", "F", "F", "F", "F")</font face=georgia>

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: If...then (2000-2002)

    You didn't explain *where* you wanted to do this and what "box" you were talking about. Are you trying to display the grade on a form or report, show it in a query, or insert it into a table?
    Charlotte

  6. #6
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If...then (2000-2002)

    Put the following function in a module and modify it to suit.

    For example you could change:

    Case 5 To 10
    fMark = "d) Between 5% and 10%"

    To:

    Case 5 To 10
    fMark = "A"

    You need to keep the text between the

  7. #7
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: If...then (2000-2002)

    ... May I just say that this is a slick way to do this...
    Regards,

    Gary
    (It's been a while!)

  8. #8
    New Lounger
    Join Date
    Apr 2002
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If...then (2000-2002)

    Charlotte,
    Thanks for replying. What I want to do is put the grade info in a box in a form or report. So I guess I want to link the box to the grade field in a table, but instead of displaying an number, I want the box to display a letter grade. Hope this makes it a bit more clear.

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: If...then (2000-2002)

    In that case, one of the suggestions using built in functions like Choose or Switch can be used in the underlying query to generate a grade letter on the fly for your form or report. That does two things for you: it displays the grade but will not allow it to be edited, and it keeps you from having to store a letter grade in a table, since it can be generated whenever you need to display it.
    Charlotte

Posting Permissions

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