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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox Referencing

Status
Not open for further replies.

mrf1xa

Technical User
Jan 14, 2002
366
GB
Hi all, missing something simple I think but can't work out what!

I have a number of chechboxes on an Excel sheet and need to make them visible or not depending on other parameters. The following works of course:

If tp = "Y" Then 'make all checkboxes invisible
Me.CON1.Visible = False
Else 'make them all visible
Me.CON1.Visible = True
End If

But I have boxes number Con1 to Con10 which I'd like to loop, so have tried as below, what am I missing please?

Dim i As Integer
If tp = "Y" Then 'make all checkboxes invisible
For i = 1 To 10
Me.CON(i).Visible = False
Next i
Else 'make them all visible
For i = 1 To 10
Me.CON(i).Visible = True
Next i
End If

Thanks

Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
You can reference controls by name (code below for named CON1,...,CON10):

Me.OLEObjects("CON" & i).Visible = False

combo
 
Perfect, thanks very much!!

Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top