Help with simple Function? 
Author Message
 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



Sun, 02 Jul 2000 03:00:00 GMT  
 Help with simple Function?

Is the control your using for ""=SetDocType([Trad850])"" a bound control on the
report or an unbound control?

Quote:
>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



Sun, 02 Jul 2000 03:00:00 GMT  
 Help with simple Function?

Hi Ed,

Try defining your parameter as Variant

Quote:

> 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

--
Rob Goudvis




Tue, 04 Jul 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help on Simple Function

2. HELP, SIMPLE Function returns wrong value!

3. HELP: how to declare a simple C function?

4. need help in simple program, very simple

5. SIMPLE SIMPLE ListView Question. Please help

6. HELP! simple question need simple answer

7. HELP! simple question need simple answer

8. HELP! simple question need simple answer

9. help, help, help...I'm begging here :-\ RE RE POST simple code help needed

10. My expressions won't work (simple left or between functions)

11. Simple Access search function?

12. Simple Function doesn't maintain focus when condition met

 

 
Powered by phpBB® Forum Software