Question : Datepart / Week part in reverse

If I have the Year as a variable, the Week of the year as a variable and know that I want the week to start on Monday(2), is there a simple way on a form to put these variables into a textbox control source and return a datevalue?
For example: Year = 2004, Week = 11, weekstart = 2, I would want to get the textbox to show
3/9/2004

Answer : Datepart / Week part in reverse

re. "...wouldn't it know...": Unfortunately, Access claims ignorance on this one.

I've mulled it about, and the only solution to your problem appears to be a function.
Access doesn't let you specify [firstdayofweek] & [firstweekofyear] when using the DateAdd function as it does when using DateDiff. Otherwise, this would be simpler.

So...
To get the 11th Monday of 2004 (which is actually 3/15/2004 because DateDiff:
NthWeekday(2004, vbMonday, 11)
where:
--------------------------------
Public Function NthWeekday(myYear As Integer, myWeekDay As Variant, WeekNo As Double)
Dim FirstDayOfYear As Date
Dim x As Integer
Dim eDate As Date

FirstDayOfYear = "1/1/" & myYear
eDate = DateAdd("ww", WeekNo - 1, FirstDayOfYear)

x = WeekDay(eDate, vbSunday) - myWeekDay

Select Case x
    Case Is >= 0
        NthWeekday = DateAdd("d", 7 - x, eDate)
    Case Else
        NthWeekday = DateAdd("d", x, eDate)
End Select

End Function
----------------------------------------------
Hope this helps.
dm
Random Solutions  
 
programming4us programming4us