Connecting Tech Pros Worldwide Forums | Help | Site Map

Creating a report based on field values

Newbie
 
Join Date: Mar 2008
Posts: 3
#1: Mar 9 '08
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's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,214
#2: Mar 10 '08

re: Creating a report based on field values


Quote:

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.
    Expand|Select|Wrap|Line Numbers
    1. Private varTestResults As Variant
  3. Copy and Paste similar code to the Format Event in the Detail Section of Report1:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    2. varTestResults = Me![delsum]
    3.  
    4. If IsNull(varTestResults) Then
    5.   Me![txtResults] = "No Grade Listed"
    6. ElseIf varTestResults >= 96 Then
    7.   Me![txtResults] = "WOW!"
    8. ElseIf varTestResults >= 85 And varTestResults <= 95 Then
    9.   Me![txtResults] = "Great!"
    10. ElseIf varTestResults >= 75 And varTestResults <= 84 Then
    11.   Me![txtResults] = "Good!"
    12. ElseIf varTestResults <= 74 Then
    13.   Me![txtResults] = "EL STINKO!"
    14. End If
    15. End Sub
  4. The code has been tested and is fully functional, let me know how you make out.
Newbie
 
Join Date: Mar 2008
Posts: 3
#3: Mar 10 '08

re: Creating a report based on field values


Quote:

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.
    Expand|Select|Wrap|Line Numbers
    1. Private varTestResults As Variant
  3. Copy and Paste similar code to the Format Event in the Detail Section of Report1:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    2. varTestResults = Me![delsum]
    3.  
    4. If IsNull(varTestResults) Then
    5.   Me![txtResults] = "No Grade Listed"
    6. ElseIf varTestResults >= 96 Then
    7.   Me![txtResults] = "WOW!"
    8. ElseIf varTestResults >= 85 And varTestResults <= 95 Then
    9.   Me![txtResults] = "Great!"
    10. ElseIf varTestResults >= 75 And varTestResults <= 84 Then
    11.   Me![txtResults] = "Good!"
    12. ElseIf varTestResults <= 74 Then
    13.   Me![txtResults] = "EL STINKO!"
    14. End If
    15. End Sub
  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.
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,214
#4: Mar 11 '08

re: Creating a report based on field values


Quote:

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.
Reply