Forum Discussion
Validating that data was entered into a text Box
Make the operational code in the buttons' Click event procedures conditional on neither text box control being Null or containing a zero-length string, e.g.
Private Sub cmdEnter_Click()
Const MESSAGE_TEXT = "Both a valid user name and password must be entered."
If Nz(Me.txtName,"") = "" Or Nz(Me.txtPassword,"") = "" Then
MsgBox MESSAGE_TEXT, vbExclamation, "Invalid Operation"
Else
' operational code goes here
End If
End Sub
Private Sub cmdAddUser_Click()
Const MESSAGE_TEXT = "Both a valid user name and password must be entered."
If Nz(Me.txtName,"") = "" Or Nz(Me.txtPassword,"") = "" Then
MsgBox MESSAGE_TEXT, vbExclamation, "Invalid Operation"
Else
' operational code goes here
End If
End Sub