G
Guest
I'm trying to use a Sub Procedure with optional arguments but I keep getting
an error when I call the procedure excluding the optional arguments. I've
tried overloading the procedure but I get another error.
The error I'm getting is "Run Tim Error '19': Object variable or with block
variable not set"
When I click Debug it highlights the code with the ****
Sub setVisible(ctl1 As Control, ctlVis1 As Boolean, Optional ctl2 As
Control, _
Optional ctlVis2 As Boolean, Optional ctl3 As Control, _
Optional ctlVis3 As Boolean, Optional ctl4 As Control, _
Optional ctlvis4 As Boolean)
ctl1.Visible = ctlVis1
If Not IsMissing(ctl2) _
Then
ctl2.Visible = ctlVis2
End If
If Not IsMissing(ctl3) _
Then
ctl3.Visible = ctlVis3 ****
End If
If Not IsMissing(ctl4) _
Then
ctl4.Visible = ctlvis4
End If
End Sub
I'm passing Controls to the procedure; ComboBoxes, ListBoxes, Rectangles,
and Buttons.
In the debug mode when I put my mouse over the ctl3 it says "ctl3=Nothing"
so I tried adding And Not ctl3 = Nothing but then I get the Error "Invalid
use of Object"
I've also tried adding And Not IsNull(ctl3) that didn't work either.
I tried looking through this website and the help files to find a function
that checks to see if the control is initialized but I haven't found anything.
Any help would be apreciated - Thanks
an error when I call the procedure excluding the optional arguments. I've
tried overloading the procedure but I get another error.
The error I'm getting is "Run Tim Error '19': Object variable or with block
variable not set"
When I click Debug it highlights the code with the ****
Sub setVisible(ctl1 As Control, ctlVis1 As Boolean, Optional ctl2 As
Control, _
Optional ctlVis2 As Boolean, Optional ctl3 As Control, _
Optional ctlVis3 As Boolean, Optional ctl4 As Control, _
Optional ctlvis4 As Boolean)
ctl1.Visible = ctlVis1
If Not IsMissing(ctl2) _
Then
ctl2.Visible = ctlVis2
End If
If Not IsMissing(ctl3) _
Then
ctl3.Visible = ctlVis3 ****
End If
If Not IsMissing(ctl4) _
Then
ctl4.Visible = ctlvis4
End If
End Sub
I'm passing Controls to the procedure; ComboBoxes, ListBoxes, Rectangles,
and Buttons.
In the debug mode when I put my mouse over the ctl3 it says "ctl3=Nothing"
so I tried adding And Not ctl3 = Nothing but then I get the Error "Invalid
use of Object"
I've also tried adding And Not IsNull(ctl3) that didn't work either.
I tried looking through this website and the help files to find a function
that checks to see if the control is initialized but I haven't found anything.
Any help would be apreciated - Thanks