Question How to access controls in another form

bennyca

New member
Joined
Jul 30, 2011
Messages
1
Programming Experience
5-10
Hi, I am trying to write general function to set the attributes of the command button and want to access this function from any forms.
But I am getting error in this function.

Public Sub SetButtonAttribute(ByRef frm As System.Windows.Forms.Form, ByRef bVal As Boolean)
On Error Resume Next
With frm
' Error Control cmdAdd could not be resolved because it was within the generic namespace Form.
.cmdAdd.Visible = bVal
.cmdEdit.Visible = bVal
End With
End Sub


Please help me
 
Pass the button reference instead of the form reference.

Also, remove the ByRef on your parameters.
 
Back
Top