I have multiple reports that use similar IIF statements as the controlsource for four textboxes. Naturally, I don't want to have to update twelve controlsources if any of the calculations change, so I thought I'd make this a public function. However, I don't know how to pass along multiple textboxes as variables. Here's what I have so far:
And this is in the report (where ??? is what I'm asking about)
The error I get is "Runtime 424 Object Required"
Code:
Option Compare Database
Public Function txtColor(ByRef textbox As Control)
Dim str1, str2, str3, str4 As String
'The IIf statement is simplified for this example. It's not important.
str1 = "=IIf(IsNull([Inquiry start date]),'W',IIf([txtInquiry]<1 And IsNull([Inquiry end date]),'R'))"
str2 = Replace(str1, "Inquiry", "Design")
str3 = Replace(str1, "Inquiry", "Enable")
str4 = Replace(str1, "Inquiry", "Assure")
txtInquiryColor.ControlSource = str1
txtDesignColor.ControlSource = str2
txtEnableColor.ControlSource = str3
txtAssureColor.ControlSource = str4
End Function
And this is in the report (where ??? is what I'm asking about)
Code:
Private Sub Report_Load()
Call txtColor(???)
End Sub
The error I get is "Runtime 424 Object Required"