I'm trying to use a user-defined function with the fields portion of a SELECT query, for example:
SELECT MyFunction([client_value]) AS new_client_value FROM client_info;
The function is defined as follows:
Public Function MyFunction(client_id)
If (client_id = 1) Then
MyFunction = 50
ElseIf client_id = 2 Then
MyFunction = 86
Else
MyFunction = 98
End If
End Function
Problem: When I try to run the query, I get an error claiming the function is undefined. I tried defining it within a Class module and within a Form class, but neither worked. Is this even possible, and if so, will it work within a UNION query?
Any help would be greatly appreciated. This forum has saved my hide many times.
SELECT MyFunction([client_value]) AS new_client_value FROM client_info;
The function is defined as follows:
Public Function MyFunction(client_id)
If (client_id = 1) Then
MyFunction = 50
ElseIf client_id = 2 Then
MyFunction = 86
Else
MyFunction = 98
End If
End Function
Problem: When I try to run the query, I get an error claiming the function is undefined. I tried defining it within a Class module and within a Form class, but neither worked. Is this even possible, and if so, will it work within a UNION query?
Any help would be greatly appreciated. This forum has saved my hide many times.