Code to auto fill txt/cbo boxes



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!
.



Relevant Pages

  • RE: Code to auto fill txt/cbo boxes
    ... Just a thought here, don't know if it will work for you, but if the shift ... as a date flag, then use code to determine if it's been two weeks since ... Private Sub Form_Load ... Sub ShiftName() ...
    (microsoft.public.access.formscoding)
  • sitemap generator for Perl
    ... I want to run the sitemap generator ... Returns the minimum number of links to traverse from the root URL of ... my $class = shift; ...
    (perl.beginners)
  • Re: How can I create instantiable objects (not classes)?
    ... a child object inherits not only its parent object's ... sub fee { ... my $class = shift; ... For example, an object of type Car might receive a message named "ticket," and since a car does not know what to do with a ticket, it would pass that message to an object of type Driver. ...
    (comp.lang.perl.misc)
  • Re: Packages and returning errors
    ... > array intact. ... sub is_a_instance_method { ... my $class = shift; ... You need to fix the scope of $error by moving its declaration outside ...
    (comp.lang.perl.misc)
  • Re: passing database data to a sub
    ... > I'm not sure of the difference, why isn't it a subroutine? ... > sure about this 'shift' thing anyway :-) ... > sub teardown ... > # Setup the template to use for the output. ...
    (perl.beginners)