Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check ALL the components in a Form 1

Status
Not open for further replies.

tutuster

Programmer
Feb 2, 2005
41
FI
I have a form with lots of contols. I'd need to do some data checking before I take the data to datatable. For example, I need to check all the textboxes in the form to see whether they are empty or not.

I can get to some of the textboxes, but I can't get to the textboxes that are inside a groupbox. Therefore i would need a recursive function to loop all the controls.

Of course, I could write tons of code to check all the textboxes, but a simple recursive function would be better since there are many txtboxes.

Any ideas?
 
Sample recursive checking code below
Call the routine by passing in a top level control to drill down into
Me.zCheckControls(Me) - will search the entire form
Code:
Private sub zCheckControls(ByVal TopControl as Control)

For Each c As Control In TopControl.Controls

'Does the control contain other controls
If c.Controls.Count > 0 Then
      Me.zCheckControls(c)
End If

If TypeOf c Is TextBox Then
'Your Checking Code
End If

Next



Sweep
...if it works dont mess with it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top