BobDennison
Programmer
I find that I am concatenating 3 fields together alot so I thought I would create a custom function. The problem is that sometimes the 2nd and/or 3rd elements can be either numeric or alpha data (as defined in their respective databases). I would like to be able to pass the 3 variables to a function, test them to see if they are numeric and convert them to text if they are. Then the function would return a string containing the concatenated value.
Here is a code snippet of what I am trying to do. Can this be done?
Function (StringVar anyfield1, StringVar anyfield2, StringVar anyfield3)
If isNumeric(anyfield2) then
anyfield1 & "-" & toText(anyfield2,'#',0) & "-" & anyfield3
Else
anyfield1 & "-" & anyfield2 & "-" & anyfield3;
(this code is only checking to see if the second value is a number. I haven't even begun to address the 3rd value since I can't get this to work yet).
The problem is that this does not work if the anyfield2 or anyfield3 data types in the table are defined as numeric (which they are in some of our databases, even though they will always be numbers). I was hoping not to have to create multiple custom functions to handle all possible cases of combinations of alpha and numeric data.
Do I have to have the report writers that want to use this function convert their "anyfield2" and "anyfield3" values to text before they can pass it to the function? Any help would be appreciated.
Here is a code snippet of what I am trying to do. Can this be done?
Function (StringVar anyfield1, StringVar anyfield2, StringVar anyfield3)
If isNumeric(anyfield2) then
anyfield1 & "-" & toText(anyfield2,'#',0) & "-" & anyfield3
Else
anyfield1 & "-" & anyfield2 & "-" & anyfield3;
(this code is only checking to see if the second value is a number. I haven't even begun to address the 3rd value since I can't get this to work yet).
The problem is that this does not work if the anyfield2 or anyfield3 data types in the table are defined as numeric (which they are in some of our databases, even though they will always be numbers). I was hoping not to have to create multiple custom functions to handle all possible cases of combinations of alpha and numeric data.
Do I have to have the report writers that want to use this function convert their "anyfield2" and "anyfield3" values to text before they can pass it to the function? Any help would be appreciated.