achalrikhi
New Member
- Joined
- Nov 20, 2013
- Messages
- 38
Dear all,
I am working on a form which have several text boxes. I want all the fields to resist when it is left blank. So I have used this code in the next textbox's gotfocus event, for each field :
Private Sub TxtCustAdd_GotFocus()
If IsNull(TxtCustName.Value) Then
MsgBox " Please enter a name "
Me.TxtCustName.SetFocus
End If
End Sub
This works fine. Simultaneously, I want the form with blank text boxes when it loads up. If I use the code to blank the text box like :
Private Sub Form_Load()
TxtCustID.Value = ""
TxtCustName.Value = ""
TxtCustAdd.Value = ""
End Sub
this works fine. But then the first code does not work and it allows to go for next text box allowing the previous one blank.
Please comment and suggest
Regards
Achal
I am working on a form which have several text boxes. I want all the fields to resist when it is left blank. So I have used this code in the next textbox's gotfocus event, for each field :
Private Sub TxtCustAdd_GotFocus()
If IsNull(TxtCustName.Value) Then
MsgBox " Please enter a name "
Me.TxtCustName.SetFocus
End If
End Sub
This works fine. Simultaneously, I want the form with blank text boxes when it loads up. If I use the code to blank the text box like :
Private Sub Form_Load()
TxtCustID.Value = ""
TxtCustName.Value = ""
TxtCustAdd.Value = ""
End Sub
this works fine. But then the first code does not work and it allows to go for next text box allowing the previous one blank.
Please comment and suggest
Regards
Achal