Page 1 of 1

How To Detect Empty Textbox Before Updating Record

Posted: Wed Mar 17, 2010 10:09 pm
by gougou
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

Re: How To Detect Empty Textbox Before Updating Record

Posted: Wed Mar 17, 2010 10:15 pm
by Neo
Good example that covers some rare keywords in VB like For Each, In, TypeOf, Is