G
Guest
I have a crosstab query that is used as the source for a form. As a result,
the crosstab columns need to be constant. I therefore use a function within
the crosstab query to allocate the data to this week ("0"), last week ("-1")
and so on. The function is as follows:
Function weeks(week_no As String) As String
Dim week_today As Integer
week_today = Val(Format(Date, "ww"))
Select Case Val(week_no)
Case week_today
weeks = "0"
Case week_today - 1
weeks = "-1"
Case week_today - 2
weeks = "-2"
Case week_today - 3
weeks = "-3"
Case week_today - 4
weeks = "-4"
Case Else
weeks = ">4"
End Select
End Function
This has woked fine until the new year when the week numbers were reset to
zero. Can anyone help me out with a function that will work all year round.
Thanks and happy new year to you all.
the crosstab columns need to be constant. I therefore use a function within
the crosstab query to allocate the data to this week ("0"), last week ("-1")
and so on. The function is as follows:
Function weeks(week_no As String) As String
Dim week_today As Integer
week_today = Val(Format(Date, "ww"))
Select Case Val(week_no)
Case week_today
weeks = "0"
Case week_today - 1
weeks = "-1"
Case week_today - 2
weeks = "-2"
Case week_today - 3
weeks = "-3"
Case week_today - 4
weeks = "-4"
Case Else
weeks = ">4"
End Select
End Function
This has woked fine until the new year when the week numbers were reset to
zero. Can anyone help me out with a function that will work all year round.
Thanks and happy new year to you all.