Article ID: 189923
Article Last Modified on 5/13/2003
Caption = Command&1
Cancel = True
CausesValidation = True
Default = True
Option Explicit
Private Sub Text1_Validate(Cancel As Boolean)
' Ensure Text1 has data else keep focus in Text1:
If Trim(Text1.Text) = "" Then Cancel = True
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
Private Sub Command1_Click()
Dim ctl As Control
' Validation code for all controls that need validating:
' Set ctl to current control in which to validate:
Set ctl = Screen.ActiveControl
If TypeOf ctl Is TextBox Then
If ctl.Name = "Text1" Then
' Validation code for Text1:
If Trim(Text1.Text) = "" Then
' Exit this procedure. Focus remains in Text1
Exit Sub
End If
End If
End If
' If Validation passes for all controls, the following
' code will execute:
Unload Me
End Sub
Additional query words: kbDSD kbDSupport kbVBp kbVBp600 kbCtrl
Keywords: kbprb KB189923