Hi,
More practical, and if possible in your case, is to go the database way:
make a table with two fields, one for the week number, one for the check
box. In the first time, the user check/uncheck the desired weeks and, once
done, make a query, JOINning that table to the original data, through the
week number, and present the resulting recordset in a continuous form view.
The "database" way is simply stated as "avoid an arrangement where a
modification will imply touching again the code". As example, there are
years with 53 weeks, so, what you do with fixed labels? With a table in a
database, just add a record to a table, no need to touch the code again.
Similar, imagine a form with three radio buttons. What happen if a fourth
one is required? And you modify the form, and maybe the code. Replacing
those with a combo-box where the list allow a selection with a fourth or a
fifth option easily added without changing any piece of the GUI neither a
single line of the code. Same thing for the laws of normalization of data,
some can be seen as an extension of that principle.
Hope it may help,
Vanderghast, Access MVP.
Quote:
>I am relatively new to VBA (I tend to use VB). I am trying to develop an
>application that shows all the weeks in the Year - effectively 52 Label
>boxes at the top of my form. As this is a little unwieldy, I have inserted
a
>list box that allows you to select a week number - this then hides all the
>previous weeks by setting the label.visible to false. This has meant a lot
>of code. I would rather do this by the preffered method and use a control
>array. VBA (access) will not let me do this - I cannot seem to manipulate
>multiple controls in one quick swoop.
>In VB5 I would use the control array method i.e.
>for n=0 to 5
>cmdbutton(n).width = 4000
>next n
>This (I'm sure its fairly apparent) would set the width automatically on 6
>command buttons to 4000. I cannot seem to do this in VBA and no one seems
to
>know how to do it. If anyone knows how to get around this, please email me
>and let me know. It's driving me up the wall....