I've got 24 textboxes and 24 checkboxes on a form. An earlier routine sets the textbox visible property to True only if it contains text. This routine sets the checkbox visible property based on the textbox to which it relates.
This is the code I'm currently using:
If Me.[ANSWER A].Visible = True Then
Me.CheckA.Visible = True
Else
Me.CheckA.Visible = False
End If
If Me.[ANSWER B].Visible = True Then
Me.CheckB.Visible = True
Else
Me.CheckB.Visible = False
End If
If Me.[ANSWER C].Visible = True Then
Me.CheckC.Visible = True
Else
Me.CheckC.Visible = False
End If
et cetera! [thru X]
Obviously, I would like to write a for loop (for items A thru X). I'm used to writing code in scripting languages like unix shells, awk, sed, etc. In those languages I was able to use command line substitution. So I would love to be able to do this (syntax notwithstanding):
For Each Item In "A", "B", "C", ... , "X"
If Me.[ANSWER $Item].Visible = True Then
Me.Check$Item.Visible = True
Else
Me.Check$Item.Visible = False
End If
Next Item
Shouldn't this be easy to do? I'm not as familiar with the VB/VBA functions as I am with the functions of other languages. I thought maybe I could use EVAL?
Any ideas?
This is the code I'm currently using:
If Me.[ANSWER A].Visible = True Then
Me.CheckA.Visible = True
Else
Me.CheckA.Visible = False
End If
If Me.[ANSWER B].Visible = True Then
Me.CheckB.Visible = True
Else
Me.CheckB.Visible = False
End If
If Me.[ANSWER C].Visible = True Then
Me.CheckC.Visible = True
Else
Me.CheckC.Visible = False
End If
et cetera! [thru X]
Obviously, I would like to write a for loop (for items A thru X). I'm used to writing code in scripting languages like unix shells, awk, sed, etc. In those languages I was able to use command line substitution. So I would love to be able to do this (syntax notwithstanding):
For Each Item In "A", "B", "C", ... , "X"
If Me.[ANSWER $Item].Visible = True Then
Me.Check$Item.Visible = True
Else
Me.Check$Item.Visible = False
End If
Next Item
Shouldn't this be easy to do? I'm not as familiar with the VB/VBA functions as I am with the functions of other languages. I thought maybe I could use EVAL?
Any ideas?