Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    two_smooth's Avatar
    two_smooth is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    19

    Populating a "Text" field in a Report

    Hello Access Forum Members,



    My issue is, I have two "text" boxes on a report (text box 1 and text box 2). Text box 1 has the expression "=[data1]+[data2]+[data3]+[data4]". The results are stored/printed in text box 1 of the report.

    I need to take the results in "text box 1" using less than and greater than logic (expressions) and set the results of text box 2 based on a series of "ranges". The logic for the ranges are as follows:

    If text box 1 results are greater than 500, text box 2 equals a value of "GOLD";
    If text box 1 results are between 400 and 499, text box 2 equals a value of "SILVER";
    If text box 1 results are between 300 and 399, text box 2 equals a value of "BRONZE";

    HELP PLEASE, ASAP

  2. #2
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    Hi,

    Set this as the control source of text box 2:

    Code:
    =IIf(([data1]+[data2]+[data3]+[data4])>=500,"Gold",IIf(([data1]+[data2]+[data3]+[data4])>=400,"Silver",IIf(([data1]+[data2]+[data3]+[data4])>=300,"Bronze","")))
    Cheers,

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did the solution supplied by ConneXionLost work for you?

  4. #4
    two_smooth's Avatar
    two_smooth is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    19
    No, it did not work. Text box two displyed as "blank".

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try this as the ControlSource of [Text Box 2] as a test:
    =IIf([Text Box 1]<>0,"Gold","Bronze")
    ...using the actual names of the controls of course.

  6. #6
    two_smooth's Avatar
    two_smooth is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    19
    RG,

    I tried your test suggestion and with one record having a value of 500 in text box 1 it displayed "GOLD", all other records displayed, "BRONZE".

    two_smooth

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So all other records are 0 or are they Null (no value)?

  8. #8
    two_smooth's Avatar
    two_smooth is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    19
    RG,

    Yes, all the other records are "0 or null".

    two_smooth

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So TextBox1 is bound to a Text field and not all of the fields have been initialized, right? Numeric fields do not allow Nulls and will initialize to 0.

  10. #10
    two_smooth's Avatar
    two_smooth is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    19
    RG,

    Text box 1 is a computed field from data fields in the record (=[data1]+[data2]+....). Data1 and all other data# fields are initialized to "0".

    two_smooth

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    OK, try ConneXionLost's suggestion but make a slight change:
    =IIf([TextBox1]>=500,"Gold",IIf([TextBox1]>=400,"Silver",IIf([TextBox1]>=300,"Bronze","")))

  12. #12
    two_smooth's Avatar
    two_smooth is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    19
    RG,

    I've tried ConneXionLost's with your suggested slight change as follows:

    =IIf([Text1]>=500,"GOLD",IIf([Text1]>=400,"SILVER",IIf([Text1]>=300,"BRONZE",IIf([Text1]>=200,"HONORABLE MENTION"""))))

    I populated four records as follows:
    Text1=500
    Text1=400
    Text1=300
    Text1=200

    The report only displayed Text2="GOLD", the other three records for Text1 and Text2 displayed "blanks/null" values.

    two_smooth

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I never liked those nested IIF's anyway. How about creating a function in your Report Class module that returns the proper results? I would probably use a Select Case structure.

  14. #14
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Your function is going to look something like:
    Code:
    Function Award(InValue As Variant) As String
        Select Case Nz(InValue, 0)
            Case Is >= 500
                Award = "GOLD"
            Case Is >= 400
                Award = "SILVER"
            Case Is >= 300
                Award = "BRONZE"
            Case Else
                Award = ""
        End Select
    End Function
    ...and the ControlSource of [TextBox 2] will be:
    =Award([Text Box 1])

  15. #15
    two_smooth's Avatar
    two_smooth is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    19
    RG,

    Exactly where do I "code" the function?

    two_smooth

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. replace a empty field with the word "none" how??
    By techexpressinc in forum Queries
    Replies: 1
    Last Post: 01-15-2010, 11:02 AM
  2. Error message and How do I find the "value Field" ?
    By createdwithfire in forum Forms
    Replies: 1
    Last Post: 11-05-2009, 12:26 PM
  3. aSTR = Dir("C:\*.*") >> "Type Mismatch"
    By JGrant in forum Programming
    Replies: 1
    Last Post: 03-28-2009, 05:17 AM
  4. Replies: 0
    Last Post: 02-24-2009, 12:37 PM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums