Vince,
You need to check that the type of the control is the one you want to affect. If your command loop is running as you put it here you are disabling all controls on the form, not just command buttons. What you need to do is the following:
For Each ctrl In xObj.Controls
If TypeOf ctrl Is CommandButton Then
ctrl.Enabled = Not ctrl.Enabled
End If
Next
For the text boxes the check is
TextBox, and you want to use the Text property instead of the Enabled as in the example above. Your text box example errors because some controls don't have a Text property. HTH
>I recently used the algorithm:
>
>Public Sub setPropsOnNavRoutineButtons(condition)
> ' Loops through each control on the form and sets the enabled condition
> Dim formControl As Control
> For Each formControl In frmNavRoutines.Controls()
> formControl.Enabled = condition
> Next formControl
>End Sub
>
>to enable/disable all the command buttons on a form.
>
>I now have a need to clear all textboxes on a form with controls other than just text boxes.
>
>I tried:
>
>Public Sub clearFields()
> 'Loops through each textbox on the form and sets text = ""
> Dim tBox As textBox
> 'For Each textBox In frmHomeSchoolTable.Controls()
> For Each tBox In gActiveForm.Controls()
> tBox.Text = ""
> Next tBox
>End Sub
>
>Blows on the for each statement (data type mismatch). Any ideas??
>thanx