INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- Turn Off Ad Banners
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...Keep up the good work - excellent site - i'd been looking for something like this for ages !..."
Geography
Where in the world do Tek-Tips members come from?
|
Visual Basic(Microsoft) Databases FAQ
|
Form Field Validation
|
How do I validate all controls for null values in one statement?
Posted: 10 Jul 01
|
I have found this procedure to be very helpful for form validation. It loops through the controls on the form to find out if any fields were left blank. For each field that is null, a message is displayed to the user and then focus is returned to that field in order for the user to know exactly which field to enter data on. Performing form validation within the database table will let you know of which field is null but won't set the focus to the field in which the null value exists.
Private Sub Form_BeforeUpdate(Cancel As Integer) Dim i As Integer For i = 0 To Controls.Count - 1 If TypeOf Controls(i) Is TextBox Or _ TypeOf Controls(i) Is ComboBox Then If IsNull(Controls(i)) Then MsgBox "No null values allowed" Controls(i).SetFocus End End If End If Next i End Sub |
Back to Visual Basic(Microsoft) Databases FAQ Index
Back to Visual Basic(Microsoft) Databases Forum
My FAQ Archive
Email This FAQ To A Friend |
|
 |
|