> Thanks for responding Steve,
> If the Orientation Start Date was 1/4/2006, the nearest Monday be
[quoted text clipped - 8 lines]
> Thank you again,
> Renee
Renee,
It really hepled that you included data and the expected results.
See if this works:
Create a standard module and paste in the following code:
'--------------------------------------------------------------------
'
' Calculates the phase (Orientation or Probation) and
' the week number of a group of participants
'
' Arguments:
' O_Start - Orientation start date as a date
' P_Start - Probation start date as a date
' ProjEnd - Project end date as a date
'
' Returns: a string
'
' Usage:
' As control source:
' using static dates =
fPhaseWeek(#1/1/2006#,#2/1/2006#,#2/17/2006#)
' using variables (fields) =
fPhaseWeek([dteOrient],[dteProb],[dteProjEnd])
'
' In a query:
' PW: fPhaseWeek([dteOrient],[dteProb],[dteProjEnd])
' ( field names ^^ ^^ ^^ )
'--------------------------------------------------------------------
Public Function fPhaseWeek(O_start As Date, P_Start As Date, ProjEnd As
Date) As String
Dim O_Monday As Date
Dim P_Monday As Date
' calc nearest Monday for Orientation ( - might be able to delete this)
If Weekday(O_start, vbMonday) = 1 Then
O_Monday = O_start
Else
O_Monday = O_start + 8 - Weekday(O_start, vbMonday)
End If
' calc nearest Monday for Probation ( - need this)
If Weekday(P_Start, vbMonday) = 1 Then
P_Monday = P_Start
Else
P_Monday = P_Start + 8 - Weekday(P_Start, vbMonday)
End If
'calc the phase and the week number
If ProjEnd < P_Monday Then
fPhaseWeek = "Orientation week " & DatePart("ww", ProjEnd)
Else
fPhaseWeek = "Probation week " & DatePart("ww", ProjEnd) -
DatePart("ww", P_Monday) + 1
End If
End Functio
'--------------------------------------------------------------------------------
Save the module.
In a query, you need an Orientation field, Probation field and a Project end
field.
Then create a calculated field like
PW: fPhaseWeek(Orientation, Probation, ProjectEnd)
(or whatever you field names are)
On the form, the control source for a textbox would be: PW
HTH

Signature
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)