If you want to use less code, try the following:
#1 Create a function with the following code....
Public Function SetControls(myselect As Byte)
Dim i As Byte
For i = 1 To 4
Me.Controls("text" & i).Visible = (i = myselect)
Next i
End Function
#2 In your Current event of the form, place the following code...
Setcontrols 5 ' All controls will be hidden, no match.
#3 In the click event of each command button, place the following code...
Setcontrols <the number of the object you want visible>
EXPLANATION:
The visible property will set itself based on the true/false condition of the value passed to the function. If a false is returned by the expression, the control (ie. subform) will be set to false, or true if the numbers match.
Less code, less work, and reusable for higher volume of controls. The same principle can be applied to setting the "state" of a form and its controls. Yes, you could use a sub instead of a function, but who cares.
Hope this makes things easier and for future endeavors.
Gary
gwinn7e
A+, N+, I+