J
Josh
I'm using continuous forms to match as close as possible an excel file. At the
end of each day, I export the day's info to this excel file, which is then
emailed to a business which requires excel files.
(just trying to explain why I did it this way in the first place)
It has worked fine for a couple of years, but I'm trying to clean up the code,
and looking for a way of doing the following better.
Currently, I have HEVar (HourEndingVariable), where if we are going to turn a
motor on, we schedule it for 6:00am for example. Leaving the schedule field
sets HEVar to 6 (for this example). Then, I have this in Exit Event:
If Me.HEvar = 6 Then
Me.HE1 = Me.txtTodayKW
Me.HE2 = Me.txtTodayKW
Me.HE3 = Me.txtTodayKW
Me.HE4 = Me.txtTodayKW
Me.HE5 = Me.txtTodayKW
Me.HE6 = Me.txtTomorrowKW
Me.HE7 = Me.txtTomorrowKW
Me.HE8 = Me.txtTomorrowKW
(skip the rest of this, but goes on to Hour24)
ElseIf Me.HEvar = 7 Then
Me.HE1 = Me.txtTodayKW
Me.HE2 = Me.txtTodayKW
Me.HE3 = Me.txtTodayKW
Me.HE4 = Me.txtTodayKW
Me.HE5 = Me.txtTodayKW
Me.HE6 = Me.txtTodayKW
Me.HE7 = Me.txtTomorrowKW
Me.HE8 = Me.txtTomorrowKW
etc etc......
As you can see, basically have to have an IF for each hour.
Can anyone suggest some method of having it in a Module, and do something like:
(not even attempting code, just trying to give an example)
all HE's where the hour part of the field (HE6 - 6 is the hour part of the
field name) is < HEVar, set value to Me.txtTodayKW
All HE's where the hour part of the field is >= HEVar, set value to
Me.txtTomorrowKW
Thanks, Josh
end of each day, I export the day's info to this excel file, which is then
emailed to a business which requires excel files.
(just trying to explain why I did it this way in the first place)
It has worked fine for a couple of years, but I'm trying to clean up the code,
and looking for a way of doing the following better.
Currently, I have HEVar (HourEndingVariable), where if we are going to turn a
motor on, we schedule it for 6:00am for example. Leaving the schedule field
sets HEVar to 6 (for this example). Then, I have this in Exit Event:
If Me.HEvar = 6 Then
Me.HE1 = Me.txtTodayKW
Me.HE2 = Me.txtTodayKW
Me.HE3 = Me.txtTodayKW
Me.HE4 = Me.txtTodayKW
Me.HE5 = Me.txtTodayKW
Me.HE6 = Me.txtTomorrowKW
Me.HE7 = Me.txtTomorrowKW
Me.HE8 = Me.txtTomorrowKW
(skip the rest of this, but goes on to Hour24)
ElseIf Me.HEvar = 7 Then
Me.HE1 = Me.txtTodayKW
Me.HE2 = Me.txtTodayKW
Me.HE3 = Me.txtTodayKW
Me.HE4 = Me.txtTodayKW
Me.HE5 = Me.txtTodayKW
Me.HE6 = Me.txtTodayKW
Me.HE7 = Me.txtTomorrowKW
Me.HE8 = Me.txtTomorrowKW
etc etc......
As you can see, basically have to have an IF for each hour.
Can anyone suggest some method of having it in a Module, and do something like:
(not even attempting code, just trying to give an example)
all HE's where the hour part of the field (HE6 - 6 is the hour part of the
field name) is < HEVar, set value to Me.txtTodayKW
All HE's where the hour part of the field is >= HEVar, set value to
Me.txtTomorrowKW
Thanks, Josh