|
-
Nov 25th, 2004, 03:28 AM
#1
Thread Starter
Lively Member
Validate controls MDI Form
I have a problem with validating my textboxes.
I have 3 forms: - 1 MDI and 2 MDI Childs
Textboxes on one of the MDI Childs need to be validated. Everything works fine by using the Validate procedure as long as I stay on that MDI Child.
VB Code:
Private Sub txtFCS_Validate(Index As Integer, KeepFocus As Boolean)
'Some code here
KeepFocus = True
MsgBox "Wrong Value"
End Sub
As soon as I access the menu from the MDI form or I do click on the other MDI Child my textboxes don't get validated anymore.
Any idea how to fix this?
-
Nov 25th, 2004, 03:39 PM
#2
Frenzied Member
I hope this helps you. I just added a couple of lines of code...
(Yet I wonder why you have the KeepFocus argument and I only have the Cancel one)
Here is the code I used:
VB Code:
Private Sub txtFCS_LostFocus(Index As Integer)
txtFCS_Validate Index, False
End Sub
Private Sub txtFCS_Validate(Index As Integer, Cancel As Boolean)
'Your condition here instead of "Not IsNumeric(txtFCS(Index))"
If Not IsNumeric(txtFCS(Index)) Then
Cancel = True
MsgBox "Wrong Value"
Me.SetFocus
txtFCS(Index).SetFocus
End If
End Sub
We miss you, friend...  Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
-
Nov 26th, 2004, 04:40 AM
#3
Thread Starter
Lively Member
This code works, problem starts occuring as soon as I add a menu item to the form parent.
If I click an item in the menu, it does not validate the control, it just executes the code under the menu_click event.
If I add a Label to the empty form, and add a Mousedown event.
VB Code:
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Label1.Caption = Me.Label1.Caption + 1
End Sub
The MouseDown event gets executed before the Validate event from the form which just lost focus.
Any workaround?
-
Nov 27th, 2004, 07:31 PM
#4
Frenzied Member
You mean something like this?
We miss you, friend...  Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
-
Nov 27th, 2004, 07:45 PM
#5
Frenzied Member
Oops... Sorry, wrong attachment.
We miss you, friend...  Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
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
|