'Your syntax is incorrect, this will work:
- Dim T As TextBox
-
-
Set T = Me![txtText]
-
T.Visible = False
Thanks for everybody replies
Here is what I'm really trying to do
in a form there is option button 4 and option button 6
there are also 2 hidden text fields: text0 and text2
and a button
I want when ever an option button is checked and the button clicked then one of the textboxes would become visible depending which one is still invisible
so for example checking option button 4 would turn text0 visible coz its the first textbox that is invisible, then checking option button 6 would turn text2 visible unless text0 is still invisible (option 4 hasn;t been checked) then it would turn text0 visible.
checking any option button off would turn its corresponding textbox invisible when you click the button
this is my code that sucks, doesn't work
Private Sub Command10_Click()
Dim box As TextBox
Set box = findbox()
If Option4.Value = -1 Then
Dim option4box As TextBox
Set option4box = Me![box]
option4box.Visible = True
Else
Set option4box.Visible = False
End If
If Option6.Value = -1 Then
Dim option6box As TextBox
Set option6box = Me![box]
option6box.Visible = True
Else
Set option6box.Visible = False
End If
End Sub
-----------------------------------------------
Public Function findbox() As TextBox
If Text0.Visible = False Then
Set findbox = Me![Text0]
ElseIf Text2.Visible = False Then
Set findbox = Me![Text2]
Else
MsgBox "all boxes has been used"
End If
End Function