RE: Code to auto fill txt/cbo boxes
- From: Beetle <Beetle@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 29 Mar 2008 19:50:00 -0700
Just a thought here, don't know if it will work for you, but if the shift
changes
every two weeks, how about adding a field to your (Shift?) table to use
as a date flag, then use code to determine if it's been two weeks since
the last time it was flagged. Something like;
If DateDiff("ww", [Me.DateFlag], Date) >=2 Then
If Me.ShiftTime = 1 Then
Me.ShitTime = 2
Else
Me.ShiftTime = 1
End If
Me.DateFlag = Now 'reset the date flag
End If
--
_________
Sean Bailey
"Opal" wrote:
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!
- Follow-Ups:
- RE: Code to auto fill txt/cbo boxes
- From: Beetle
- RE: Code to auto fill txt/cbo boxes
- References:
- Code to auto fill txt/cbo boxes
- From: Opal
- Code to auto fill txt/cbo boxes
- Prev by Date: Re: import error
- Next by Date: RE: Code to auto fill txt/cbo boxes
- Previous by thread: Code to auto fill txt/cbo boxes
- Next by thread: RE: Code to auto fill txt/cbo boxes
- Index(es):