AllAPI Network - The KPD-Team

 
Allapi Network
 API-Guide
 ApiViewer

 API List

 
API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
 
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
 
This Site
 Search Engine
 Contact Form
 

Donate to AllAPI.net

How to auto-detect empty textboxes for user's input before updating record in database programming

Description: We want the users to notice there is something missing in textboxes before changing forms or updating records, the following code in the update-command button serves the checking:

Code:

Option Explicit
'
Private Sub cmdUpdate_Click()
Dim ctr As Control
'
'====================================
' CHECKING EMPTY TEXTBOX SUBROUTINE
'====================================
'
'looping through the entire control collection
'in current form. "Controls" is a Collection
'of all controls on form
For Each ctr In Me.Controls
'use "TypeOf" function to identify TextBoxes
If TypeOf ctr Is TextBox Then
'check if the TextBox control has no Text
If ctr.Text = vbNullString Then
MsgBox "TextBox information missing"
ctr.SetFocus
'Setfocus back to TextBox
Exit Sub
'This is to get out
End If
End If
Next ctr
'
'====================================
'Here you need to enter what you should do
'for thus buttons (e.g., Update, Exit, New form etc.)
'in case all TextBoxes have text.
'====================================
' End Sub

Tip submitted by David Da-Teh Huang

 

 


Copyright © 1998-2007, The Mentalis.org Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at http://allapi.mentalis.org/