View Full Version : Using variables when refering to controls


johndoomed
12-20-2007, 06:35 AM
Hi,

I'm making a timemanagmentsystem. In this system there is a form that the displays the current week. With a subform for each day (I use the same subform, and set the SQL from the mainform). On each of these subforms there is a "new"-botton, for creating a new listing. I need to refer to a textfield containing a date. There are one of these textfields for each day of the week.

On the subforms, I get the number of day in the week (My english teacher would be proud of that sentence :-p), and I want to refer to the textbox containing the dates (On the mainform).

The textboxes with dates, are named: day1, day2, day3, etc.. I want to be able to refer to them with the numbervariable. Like:

StrDate = Me.Parent.Day & StrDayNumber

boblarson
12-20-2007, 06:39 AM
There are one of these textfields for each day of the week.
Definitely non-normalized if your table has repeating fields like that and you should redesign it because it will only cause you grief as you try to do things that your "spreadsheet" design doesn't take advantage of the power of relational databases.

To refer to controls by variable use:
StrDate = Me.Parent.Controls("day" & StrDayNumber).Value

johndoomed
12-20-2007, 07:07 AM
Thanks for your reply!

I'm not sure if what I got is repeating fields. I god a table containing the different listings, with this fields:

ID
Date
TimeStart
TimeDone
TimeSpent
TimeBillable
Custumer_id
Project_id
Task_id
Person_id

Are you suggesting that I should split this even further?

boblarson
12-20-2007, 07:30 AM
No, that looks fine. from your description of a control on the form for each day, it sounded like you did. Sorry about that.