|
-
Jun 24th, 2000, 12:55 PM
#1
Thread Starter
Addicted Member
I wrote this code:
Private Sub txtName_LostFocus()
Call CheckTextValidation(txtName)
End Sub
Public Function CheckTextValidation(txt As TextBox) As Boolean
If txt.Text = Empty Then
Call MsgBox("you should insert data to this field", vbExclamation + vbOKOnly, App.Title)
CheckTextValidation = False
txt.SetFocus
Else
CheckTextValidation = True
End If
End Function
But ,it doesn't work properly after it display the first
msgbox and i clicked OK it display the msgbox AGAIN !!!
PLEASE HELP
The MORE I get to know,
I realize that I know NOTHING !
-
Jun 24th, 2000, 01:01 PM
#2
Hyperactive Member
This is just a guess, but you are giving focus to the wrong textbox. Look at you code. You call the validation when TxtName losses focus, and then give focus back to txt. If these are two separate textboxes, then this is your problem, because TxtName will always be losing focus.
Hope this helps.
-
Jun 24th, 2000, 01:03 PM
#3
Hyperactive Member
Try this
That's odd... your code works for me... you can use this simplified method which should work also:
Code:
Dim CheckTextValidation As Boolean
Private Sub txtName_LostFocus()
If txtname.Text = Empty Then
Call MsgBox("you should insert data to this field", vbExclamation + vbOKOnly, App.Title)
CheckTextValidation = False
txtname.SetFocus
Else
CheckTextValidation = True
End If
End Sub
good luck
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jun 24th, 2000, 11:13 PM
#4
Are there two textboxes you use this method on?
If so, putting pocus back on the first textbox will cause loosing focus for the second, and so on.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|