How To Detect Empty Textbox Before Updating Record

Visual Basic Topics
Post Reply
User avatar
gougou
Corporal
Corporal
Posts: 7
Joined: Wed Mar 17, 2010 9:36 pm
Location: Indonesia

How To Detect Empty Textbox Before Updating Record

Post by gougou » Wed Mar 17, 2010 10:09 pm

This program will warn you if there is one or more empty textbox. You can modify it to handle empty checkbox, etc.

Code: Select all

Sub CheckEmptyTB()
    Dim ctr As Control
    
    For Each ctr In Me.Controls
        If TypeOf ctr Is TextBox Then
            MsgBox "Empty TextBox!"
            ctr.SetFocus
            Exit Sub
        End If
    Next ctr
End Sub
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How To Detect Empty Textbox Before Updating Record

Post by Neo » Wed Mar 17, 2010 10:15 pm

Good example that covers some rare keywords in VB like For Each, In, TypeOf, Is
Post Reply

Return to “Visual Basic Programming”