Hi,
I am using MSAccess 2002 Windows 2000 (stop laughing!)
I am trying to use a function to generate a string in a textbox on a form. I can't use expression builder because the expression is too long (it is HUGE). I have written a function in a module that works perfectly in the immediate window, however when I try to call the function from the textbox, I get an error.
Here is a small portion of the function (the rest will be similar and once I get this to work I know that I can get the rest to work):
Public Function HealthHazard(fl apjacks As Form) As String
Dim strHealthHaz As String
With Form_SafetyPrec autionGeneratio n
If .Suspected.Valu e <> "N/A" Then
strHealthHaz = strHealthHaz & .Suspected.Valu e & " human: "
If .Carcinogen <> False Then
strHealthHaz = "Carcinogen "
End If
If .Teratogen = True Then
strHealthHaz = strHealthHaz & Chr(13) & Chr(10) & "Teratogen"
End If
End If
End With
HealthHazard = strHealthHaz
End Function[/INDENT]
In the textbox control source I am using:
=HealthHazard([Form_SafetyPrec autionGeneratio n])
It returns #Name? in view mode
I have tried it without the "Form_" and without the brackets and I also tried
=HealthHazard([Section0])
Again, it works perfectly using
?HealthHazard(F orm_SafetyPreca utionGeneration )
in the immediate window.
Any help would be appreciated. Thanks!!
I am using MSAccess 2002 Windows 2000 (stop laughing!)
I am trying to use a function to generate a string in a textbox on a form. I can't use expression builder because the expression is too long (it is HUGE). I have written a function in a module that works perfectly in the immediate window, however when I try to call the function from the textbox, I get an error.
Here is a small portion of the function (the rest will be similar and once I get this to work I know that I can get the rest to work):
Public Function HealthHazard(fl apjacks As Form) As String
Dim strHealthHaz As String
With Form_SafetyPrec autionGeneratio n
If .Suspected.Valu e <> "N/A" Then
strHealthHaz = strHealthHaz & .Suspected.Valu e & " human: "
If .Carcinogen <> False Then
strHealthHaz = "Carcinogen "
End If
If .Teratogen = True Then
strHealthHaz = strHealthHaz & Chr(13) & Chr(10) & "Teratogen"
End If
End If
End With
HealthHazard = strHealthHaz
End Function[/INDENT]
In the textbox control source I am using:
=HealthHazard([Form_SafetyPrec autionGeneratio n])
It returns #Name? in view mode
I have tried it without the "Form_" and without the brackets and I also tried
=HealthHazard([Section0])
Again, it works perfectly using
?HealthHazard(F orm_SafetyPreca utionGeneration )
in the immediate window.
Any help would be appreciated. Thanks!!
Comment