For....Next or What

  • Thread starter Thread starter Steve Schapel
  • Start date Start date
S

Steve Schapel

Dean,

Do you mean that each of these controls on the form is bound to a field
in your table? If so, is the structure of your database set in concrete
at this stage, or can you consider a design change? There is a much
easier way to do it.
 
Dean said:
I have a number of control on a form (15 per day of the week), these
controls are to be enabled or disables depending on which button is pressed,
do I have to sit and type each control name into the code or can I do it
some other way?

Control names are Machine1Monday,
Machine1Tuesday.......etc.etc.Machine4Saturday,Machine4Sunday and for each
day of the week there is a TextBox for £20,£10,5,2,1,50p,20p,10,5,2,1 each
called MonTwentyPounds,MonTenPounds..............etc.etc.etc through to
SunTwop,SunOnep.

Can I create an array, or a group or , or , or , ...


You can use this syntax for the machine/days:

MachineNum = 3
Me("Machine" & MachineNum & "Monday").Enabled = False

Depending on what is dependent on the selected button, you
may want to change the names of the controls to make them
more amenable to this approach. You almost certainly will
want to change the names of the ...Pounds/Pence controls.

There are more indirect ways to translate a "name" to a
number, a different name or an object using an array or,
usually better, a collection, but I would need to know more
details about what depends on what before I could offer a
useful suggestion.
 
I have a number of control on a form (15 per day of the week), these
controls are to be enabled or disables depending on which button is pressed,
do I have to sit and type each control name into the code or can I do it
some other way?

Control names are Machine1Monday,
Machine1Tuesday.......etc.etc.Machine4Saturday,Machine4Sunday and for each
day of the week there is a TextBox for £20,£10,5,2,1,50p,20p,10,5,2,1 each
called MonTwentyPounds,MonTenPounds..............etc.etc.etc through to
SunTwop,SunOnep.

Can I create an array, or a group or , or , or , ...

My code is going to be immense.

Dean
 
Dean,

The specifics will depend on the details of what you are really trying
to achieve with this data. But at this stage, it looks to me like you
have fallen into the "fields as data" trap. Databases usually work
better if you use records to store your data, rather than storing some
of the information in the field names. This sometimes requires a
"thinking adjustment" for people who are accustomed, for example, to
working with spreadsheets and stuff like that. So, you might only need
a table with 4 fields:
Machine
DayName
Denomination
Quantity
.... and then you can manipulate which machine/day records you see at any
time on your form, based on filtering the data according to selectors in
the form footer.
 
Steve,

Tell me more!

Please
Steve Schapel said:
Dean,

Do you mean that each of these controls on the form is bound to a field
in your table? If so, is the structure of your database set in concrete
at this stage, or can you consider a design change? There is a much
easier way to do it.
 
Back
Top