I declared a variable as control then looped through the controls in my form
and controls that had a null or "" value I tried to add to a string called strRequired
I am having an issue with the select statement not passing the name in the case statement to that value
What am I missing??
Newbie in search of knowledge
and controls that had a null or "" value I tried to add to a string called strRequired
I am having an issue with the select statement not passing the name in the case statement to that value
What am I missing??
Code:
Private Sub CheckForNulls()
Dim ctl As Control
Dim strRequired As String
strRequired = ""
For Each ctl In Form.Controls
If TypeOf ctl Is ComboBox Or TypeOf ctl Is TextBox _
Or TypeOf ctl Is ListBox Then
If IsNull(ctl) Or ctl = "" Then
Select Case ctl.Name
Case cboSite
strRequired = strRequired + "Site" & ", "
Case cboActivity
strRequired = strRequired + "Activity" & ", "
Case txtLogin
strRequired = strRequired + "LogIn" & ", "
Case txtLogOut
strRequired = strRequired + "LogOut" & ", "
Case cboWorkDate Or txtDay
strRequired = strRequired + "Date" & ", "
End Select
End If
End If
Next
If strRequired = "" Or IsNull(strRequired) Then
InputLogInOut
Else
MsgBox strRequired & " is a required field"
'Debug.Print strRequired
End If
End Sub
Newbie in search of knowledge