|
-
Jan 11th, 2000, 09:35 PM
#1
Member
You would use what's called Form-Level validation. You can set the Form's KeyPreview property to 'True' so that the Form KeyUp, KeyDown, and KeyPress events fire before the control's KeyUp, KeyDown, and KeyPress events. You can then loop thru all of the text boxes on your form and check to see that they are full before making the command button enabled or visible. In this example, my project has several textboxes and a command button called cmdDone:
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
'make sure all textboxes have data in them and enable 'Done'
Dim cntrl As Control
Dim bEnabled As Boolean
bEnabled = True 'set to enabled
For Each cntrl In Controls
If TypeOf cntrl Is TextBox Then
If cntrl.Text = "" Then
bEnabled = False
End If
End If
Next cntrl
'now set the enabled property of the command button
cmdDone.Enabled = bEnabled
End Sub
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
|