Creating a report based on field values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Freud52
    New Member
    • Mar 2008
    • 3

    Creating a report based on field values

    I've developed a test that results in standard scores from 35 to 99. Now, i need to be able, when a score for a specific scale is, let's say, >=75 and <=84, to have a predefined block of text be placed in a report. And, if the score for that same scale is >=85 and <=94, to have another text box be placed there instead, in the same place in the report. I am no programming guru, but if i'm given a simple example, i think i'd be able to tweak it to what i need. i hope this is possible and that someone will please help me figure this out.

    Let's say my table is called mytbl and the field is called delsum, which has the value of 78. i want to be able to have a block of text placed into a report that says something like "When individuals score in such a range, thus and such can be expected, blah blah blah."

    PLEASE TELL ME THIS IS POSSIBLE
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by Freud52
    I've developed a test that results in standard scores from 35 to 99. Now, i need to be able, when a score for a specific scale is, let's say, >=75 and <=84, to have a predefined block of text be placed in a report. And, if the score for that same scale is >=85 and <=94, to have another text box be placed there instead, in the same place in the report. I am no programming guru, but if i'm given a simple example, i think i'd be able to tweak it to what i need. i hope this is possible and that someone will please help me figure this out.

    Let's say my table is called mytbl and the field is called delsum, which has the value of 78. i want to be able to have a block of text placed into a report that says something like "When individuals score in such a range, thus and such can be expected, blah blah blah."

    PLEASE TELL ME THIS IS POSSIBLE
    There are several methods which you can use to accomplish this, but this is the 1st one that comes to mind. First, a couple of assumptions:
    1. Your Report Name is Report1.
    2. You have a Table named mytbl which contains a Field (INTEGER) named [delsum].
    3. The Record Source for Report1 is mytbl.
    4. Your Report, among other Fields, contains the [delsum] Field and is named the same, namely, delsum.

    Time for the fun part!
    1. Create an Unbound Text Box on Report1 and name it txtResults.
    2. Copy and Paste the following Variable Declaration to the General Declarations Section of Report1. The Variable 'must' be Declared as Variant to allow for the possibility of Null Values for [delsum], unless the Required Property of this Field is set to True.
      [CODE=vb]Private varTestResults As Variant[/CODE]
    3. Copy and Paste similar code to the Format Event in the Detail Section of Report1:
      [CODE=vb]
      Private Sub Detail_Format(C ancel As Integer, FormatCount As Integer)
      varTestResults = Me![delsum]

      If IsNull(varTestR esults) Then
      Me![txtResults] = "No Grade Listed"
      ElseIf varTestResults >= 96 Then
      Me![txtResults] = "WOW!"
      ElseIf varTestResults >= 85 And varTestResults <= 95 Then
      Me![txtResults] = "Great!"
      ElseIf varTestResults >= 75 And varTestResults <= 84 Then
      Me![txtResults] = "Good!"
      ElseIf varTestResults <= 74 Then
      Me![txtResults] = "EL STINKO!"
      End If
      End Sub[/CODE]
    4. The code has been tested and is fully functional, let me know how you make out.

    Comment

    • Freud52
      New Member
      • Mar 2008
      • 3

      #3
      Originally posted by ADezii
      There are several methods which you can use to accomplish this, but this is the 1st one that comes to mind. First, a couple of assumptions:
      1. Your Report Name is Report1.
      2. You have a Table named mytbl which contains a Field (INTEGER) named [delsum].
      3. The Record Source for Report1 is mytbl.
      4. Your Report, among other Fields, contains the [delsum] Field and is named the same, namely, delsum.

      Time for the fun part!
      1. Create an Unbound Text Box on Report1 and name it txtResults.
      2. Copy and Paste the following Variable Declaration to the General Declarations Section of Report1. The Variable 'must' be Declared as Variant to allow for the possibility of Null Values for [delsum], unless the Required Property of this Field is set to True.
        [CODE=vb]Private varTestResults As Variant[/CODE]
      3. Copy and Paste similar code to the Format Event in the Detail Section of Report1:
        [CODE=vb]
        Private Sub Detail_Format(C ancel As Integer, FormatCount As Integer)
        varTestResults = Me![delsum]

        If IsNull(varTestR esults) Then
        Me![txtResults] = "No Grade Listed"
        ElseIf varTestResults >= 96 Then
        Me![txtResults] = "WOW!"
        ElseIf varTestResults >= 85 And varTestResults <= 95 Then
        Me![txtResults] = "Great!"
        ElseIf varTestResults >= 75 And varTestResults <= 84 Then
        Me![txtResults] = "Good!"
        ElseIf varTestResults <= 74 Then
        Me![txtResults] = "EL STINKO!"
        End If
        End Sub[/CODE]
      4. The code has been tested and is fully functional, let me know how you make out.
      My Friend!
      You are a genius!!!!
      It works perfectly. I couldn't be more pleased.
      Thank you so much for your expert help.

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by Freud52
        My Friend!
        You are a genius!!!!
        It works perfectly. I couldn't be more pleased.
        Thank you so much for your expert help.
        You are quite welcome, Freud52.

        Comment

        Working...