O
Opal
I am trying to create a database whereby certain information is
automatically filled in for the user based on the day of the week, the
week in the year and the time of the day. However, I wonder if
there is a way to do this that will not involve lots and lots of
lines of code.....
For example, I have added the following to the on load event of my
main form:
Private Sub Form_Load()
If Me.txtTime >= #6:30:00 AM# And Me.txtTime <= #5:00:00 PM# Then
Me.cboShiftTime = 1
Else: Me.cboShiftTime = 2
End If
ShiftName
End Sub
The Shift time being Days (1) or Afternoons (2). Now I want the the
code
to go to the sub named "ShiftName" whereby based on what week it is
in the year, will determine which shift is on days and which shift is
on
afternoons: i.e. Week 1 and 2, Shift 2 is on days; Week 3 and 4, Shift
1;
Week 5 and 6, Shift 2; and so on...
I started to write the following:
Sub ShiftName()
If Forms![frmMain]!txtWeekNo = 1 And Forms![frmMain]!txtShiftTime = 1
Then
Forms![frmMain]!cboShiftName = 2
Else: Forms![frmMain]!cboShiftName = 1
End If
If Forms![frmMain]!txtWeekNo = 2 And Forms![frmMain]!txtShiftTime = 1
Then
Forms![frmMain]!cboShiftName = 2
Else: Forms![frmMain]!cboShiftName = 1
End If
If Forms![frmMain]!txtWeekNo = 3 And Forms![frmMain]!txtShiftTime = 1
Then
Forms![frmMain]!cboShiftName = 1
Else: Forms![frmMain]!cboShiftName = 2
End If
If Forms![frmMain]!txtWeekNo = 4 And Forms![frmMain]!txtShiftTime = 1
Then
Forms![frmMain]!cboShiftName = 1
Else: Forms![frmMain]!cboShiftName = 2
End If
..... and started to wonder if I needed to do this 52 times.....does
anyone have
any advice? Is there a simpler way to accomplish my goal? Thanks!
automatically filled in for the user based on the day of the week, the
week in the year and the time of the day. However, I wonder if
there is a way to do this that will not involve lots and lots of
lines of code.....
For example, I have added the following to the on load event of my
main form:
Private Sub Form_Load()
If Me.txtTime >= #6:30:00 AM# And Me.txtTime <= #5:00:00 PM# Then
Me.cboShiftTime = 1
Else: Me.cboShiftTime = 2
End If
ShiftName
End Sub
The Shift time being Days (1) or Afternoons (2). Now I want the the
code
to go to the sub named "ShiftName" whereby based on what week it is
in the year, will determine which shift is on days and which shift is
on
afternoons: i.e. Week 1 and 2, Shift 2 is on days; Week 3 and 4, Shift
1;
Week 5 and 6, Shift 2; and so on...
I started to write the following:
Sub ShiftName()
If Forms![frmMain]!txtWeekNo = 1 And Forms![frmMain]!txtShiftTime = 1
Then
Forms![frmMain]!cboShiftName = 2
Else: Forms![frmMain]!cboShiftName = 1
End If
If Forms![frmMain]!txtWeekNo = 2 And Forms![frmMain]!txtShiftTime = 1
Then
Forms![frmMain]!cboShiftName = 2
Else: Forms![frmMain]!cboShiftName = 1
End If
If Forms![frmMain]!txtWeekNo = 3 And Forms![frmMain]!txtShiftTime = 1
Then
Forms![frmMain]!cboShiftName = 1
Else: Forms![frmMain]!cboShiftName = 2
End If
If Forms![frmMain]!txtWeekNo = 4 And Forms![frmMain]!txtShiftTime = 1
Then
Forms![frmMain]!cboShiftName = 1
Else: Forms![frmMain]!cboShiftName = 2
End If
..... and started to wonder if I needed to do this 52 times.....does
anyone have
any advice? Is there a simpler way to accomplish my goal? Thanks!