G
Guest
I'm trying to create a module that will take a single character code and
return the word it represents. I was using an If statement in 2 reports that
did this fine. I have to create more reports that will use this so I decided
to put the If statement in a function and then use the function in all the
reports. However, I get a compile error when I type in the line to 'call' the
function.
This is the If that was working:
If AnimalType = "D" Then
[TypeOf] = "Dog"
ElseIf AnimalType = "C" Then
[TypeOf] = "Cat"
Else
[TypeOf] = "Other"
End
End If
This above works fine. The AnimalType is from the table and the TypeOf is an
unbound field used do print the word on the report.
This is the function:
Public Function TypeAnimal(TypeOfAnimal As String) As String
If TypeOfAnimal = "D" Then
[TypeAnimal] = "Dog"
ElseIf TypeOfAnimal = "C" Then
[TypeAnimal] = "Cat"
Else
[TypeAnimal] = "Other"
End If
End Function
This is the 'call' statement on the Click Event:
TypeOf = TypeAnimal(AnimalType)
*TypeOf is the unbound field on the report that prints the word returned.*
*AnimalType is from the Animal Table*
Error message:
Expected:line number or label or statement or end of statement
Does anyone have any ideas about what's causing this?
Thanks,
RandyM
return the word it represents. I was using an If statement in 2 reports that
did this fine. I have to create more reports that will use this so I decided
to put the If statement in a function and then use the function in all the
reports. However, I get a compile error when I type in the line to 'call' the
function.
This is the If that was working:
If AnimalType = "D" Then
[TypeOf] = "Dog"
ElseIf AnimalType = "C" Then
[TypeOf] = "Cat"
Else
[TypeOf] = "Other"
End
End If
This above works fine. The AnimalType is from the table and the TypeOf is an
unbound field used do print the word on the report.
This is the function:
Public Function TypeAnimal(TypeOfAnimal As String) As String
If TypeOfAnimal = "D" Then
[TypeAnimal] = "Dog"
ElseIf TypeOfAnimal = "C" Then
[TypeAnimal] = "Cat"
Else
[TypeAnimal] = "Other"
End If
End Function
This is the 'call' statement on the Click Event:
TypeOf = TypeAnimal(AnimalType)
*TypeOf is the unbound field on the report that prints the word returned.*
*AnimalType is from the Animal Table*
Error message:
Expected:line number or label or statement or end of statement
Does anyone have any ideas about what's causing this?
Thanks,
RandyM