nileshjadhavshiv
New Member
- Joined
- Aug 15, 2013
- Messages
- 23
Hi All,
I have design & build 9 to 10 userforms. I need to validate each user-form's Textbox and optionbutton,Checkbox are selected or not if its not selected then code should be stop.
To every userform i have put below code to validate Textbox optionbutton,Checkbox are selected
Private Sub ContLbl_Click()
Dim Cnt As Control, OptBtnVal As Boolean
For Each Cnt In I_EightFrm.Controls
OptBtnVal = Cnt.Name Like "OptionButton*"
If OptBtnVal = True Then
If Cnt.Object = True Then
OB = OB + 1
End If
End If
Next
If OB < 8 Then Call CommonMsg: Exit Sub
If OptionButton84.Value = True And Trim(OthTB.Value) = "" Then Call CommonMsg: Exit Sub
End Sub
My question is i have wrote above code in every userform.is there any shortcut where i can put one time code and it will be working for all userform ( my friend told you can do it with class module but i dont know about class module)
Please help me.
I have design & build 9 to 10 userforms. I need to validate each user-form's Textbox and optionbutton,Checkbox are selected or not if its not selected then code should be stop.
To every userform i have put below code to validate Textbox optionbutton,Checkbox are selected
Private Sub ContLbl_Click()
Dim Cnt As Control, OptBtnVal As Boolean
For Each Cnt In I_EightFrm.Controls
OptBtnVal = Cnt.Name Like "OptionButton*"
If OptBtnVal = True Then
If Cnt.Object = True Then
OB = OB + 1
End If
End If
Next
If OB < 8 Then Call CommonMsg: Exit Sub
If OptionButton84.Value = True And Trim(OthTB.Value) = "" Then Call CommonMsg: Exit Sub
End Sub
My question is i have wrote above code in every userform.is there any shortcut where i can put one time code and it will be working for all userform ( my friend told you can do it with class module but i dont know about class module)
Please help me.