Forms Collection can't find form
I have a set of forms I want to change the backcolor of and the function I wrote is not finding the form within the collection. When I run the function (which is called in the formload and afterupdate of the involved controls) I get an error that says Access cannot find the form (strFormName) referred to. Stepping through the code shows the variable strFormName contains the correct form name. The collection just doesn't like it.
I'm obviously doing something wrong and can't figure it out. Can someone help please?
Thank you,
Loralee
+++++++++++++++++++++++++++++++++++++
Public Function UpdateBackcolor(strFormname As String, lngStatusid As Long)
'this function is called by frmPatient and frmReferral to update the backcolor
'based on patients status in PCG Program
If lngStatusid = 3 Then
Forms!strFormname.Detail.BackColor = conClosedColor
Else
Forms!strFormname.Detail.BackColor = conOpenColor
End If
End Function
|