Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conversion of Data from Group Control 2

Status
Not open for further replies.

Telestar

Instructor
Jul 12, 2004
7
CA
I set up a number of 3 value group controls on 3 forms in an Access database. I now have a column with values between 1 and three. That's what I expected.

Here's my problem. Friendly reports ... How do I get the values to display as text on a report. Eg.1="Present" 2="Absent" and 3="Sent Home"


I would assume an if statement, but I have looked all over for if statements in Access and can't find anything.

Thanks for any info you can lend
Telestar
 
Telestar
In the query that populates the report, have you tried using the Switch function?

Create a new column with the expression
Switch([Value]=1,"Present",[Value]=2,"Absent",[Value]=3,"Sent home")

Does that do it for you?

Tom
 
Telestar
I should have added that if you use the Switch function, then you would reference that in the report and not the former [Value] field.

Tom
 
Tom and Telestar
I you don't have a table with the lookup values, I would suggest:
1) create a function that can keeps all the values and associated lookups in one place:
Code:
Function GetAttendStatus(pintStatus as Integer) As String
   Select Case pintStatus
      Case 1
         GetAttendStatus = "Present"
      Case 2
         GetAttendStatus = "Absent"
      Case 3
         GetAttendStatus = "Sent Home"
      Case Else
         GetAttendStatus = "Smoking in the Boys' Room"
   End Select
End Function
Or
Code:
Function GetAttendStatus(pintStatus as Integer) As String
   GetAttendStatus = Choose(pintStatus,"Present","Absent","sent Home")
End Function


Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Thanks Duane!
That did the trick! Now that I see the code it sure makes sense. I did have to go back to the forms and set the default on the group to "0" when the initial record is made. It was null, and the function parameter wants an integer. All the blank fields yielded #error in the query and subsequent reports ... So we fixed up the table and presto ... results.

"Boys room smoking ...." I liked that!

I have two similar queries so both use the function.Making it global is the right thing!

You made my day!
Cheers
Bill J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top