
Help with simple Function?
I've been working with Access for years now, but have never needed to
actually write my own functions in a database. I could really use some
help in the following scenario...
I have a field in a table that shows the current status of the record.
Since I use radio buttons on forms to enter the data, and for storage
space reasons, the table just stores the data as an integer, 1 through
6. But since no one using the app understands the status codes, I need
to convert them to realistic status codes in reports. I've designed a
function, show below, that seems as if it should handle this, but it
returns #error in the particular field. I'm setting the report control
as "=SetDocType([Trad850])", which seems like it should return the
value according to the function.
Here's the Function:
Function SetDocType(intDocTypeValue As Integer) As String
Select Case intDocTypeValue
Case 1
SetDocType = "None"
Case 2
SetDocType = "Prod."
Case 3
SetDocType = "Test"
Case 4
SetDocType = "Vend. Req."
Case 5
SetDocType = "Ret. Req."
Case 6
SetDocType = "Cancelled"
Case Else
SetDocType = "Error"
End Select
End Function
As you can see, there's nothing particularly difficult here, just a
simple conversion. But I'm lost about why it won't work. Any help
would be much appreciated.
Ed