MikeAuz1979
Programmer
Hi, Using a userform in excel 2000, I want to check that the mandatory fields (With a Tag property of 'Pg1') are not blank/empty before proceding.
The code I'm using is below and all works well except for ctrl.text = "", any ideas how to check if the controls text is empty or not?
Thanks for any help
Mike
----Code Start----
dim ctrl as control
dim ValidMsg as string
For Each ctrl In frmMain.Controls
If ctrl.Tag = "Pg1" And ctrl.text = "" Then
ValidMsg = ValidMsg & vbCrLf & Mid(ctrl.Name, 4, Len(ctrl.Name) - 1)
End If
Next
If Not ValidMsg = "" Then
MsgBox "The following mandatory fields were not completed" & ValidMsg, vbCritical, "Validation Error"
Exit Sub
End If
----Code End----
The code I'm using is below and all works well except for ctrl.text = "", any ideas how to check if the controls text is empty or not?
Thanks for any help
Mike
----Code Start----
dim ctrl as control
dim ValidMsg as string
For Each ctrl In frmMain.Controls
If ctrl.Tag = "Pg1" And ctrl.text = "" Then
ValidMsg = ValidMsg & vbCrLf & Mid(ctrl.Name, 4, Len(ctrl.Name) - 1)
End If
Next
If Not ValidMsg = "" Then
MsgBox "The following mandatory fields were not completed" & ValidMsg, vbCritical, "Validation Error"
Exit Sub
End If
----Code End----