Creating a report based on field values | Newbie | | Join Date: Mar 2008
Posts: 3
| | |
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
|  | Expert | | Join Date: Apr 2006 Location: Philadelphia
Posts: 5,214
| | | 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: - Your Report Name is Report1.
- You have a Table named mytbl which contains a Field (INTEGER) named [delsum].
- The Record Source for Report1 is mytbl.
- Your Report, among other Fields, contains the [delsum] Field and is named the same, namely, delsum.
Time for the fun part!- Create an Unbound Text Box on Report1 and name it txtResults.
- 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.
- Private varTestResults As Variant
- Copy and Paste similar code to the Format Event in the Detail Section of Report1:
-
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
-
varTestResults = Me![delsum]
-
-
If IsNull(varTestResults) 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
- The code has been tested and is fully functional, let me know how you make out.
| | Newbie | | Join Date: Mar 2008
Posts: 3
| | | 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: - Your Report Name is Report1.
- You have a Table named mytbl which contains a Field (INTEGER) named [delsum].
- The Record Source for Report1 is mytbl.
- Your Report, among other Fields, contains the [delsum] Field and is named the same, namely, delsum.
Time for the fun part!- Create an Unbound Text Box on Report1 and name it txtResults.
- 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.
- Private varTestResults As Variant
- Copy and Paste similar code to the Format Event in the Detail Section of Report1:
-
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
-
varTestResults = Me![delsum]
-
-
If IsNull(varTestResults) 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
- 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.
|  | Expert | | Join Date: Apr 2006 Location: Philadelphia
Posts: 5,214
| | | 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.
|  | Similar Microsoft Access / VBA bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,419 network members.
|