Date Picker - Set certain date based on week selected

santosm
3StarLounger
Posts: 253
Joined: 19 Apr 2010, 09:01
Location: Indiana, USA

Date Picker - Set certain date based on week selected

Post by santosm »

Hi All,
This may sound a little silly, but I would like to make a control that returns the Monday date of the week that the user is selecting. In other words, no matter what day they pick in that week, I would like the returned value to be for the Monday of that week. No idea where to start on this one....

Thanks,
Mark
Thanks,
Mark

User avatar
HansV
Administrator
Posts: 78391
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Date Picker - Set certain date based on week selected

Post by HansV »

Create a text box. Name it txtDate and set its Format property to a date format. When the user activates the text box (by tabbing or clicking), Access will automatically display a calendar icon.
Create an After Update event procedure for the text box:

Code: Select all

Private Sub txtDate_AfterUpdate()
    If Not IsNull(Me.txtDate) Then
        Me.txtDate = Me.txtDate - Weekday(Me.txtDate) + 2
    End If
End Sub
Best wishes,
Hans

santosm
3StarLounger
Posts: 253
Joined: 19 Apr 2010, 09:01
Location: Indiana, USA

Re: Date Picker - Set certain date based on week selected

Post by santosm »

Hi Hans,
Works great!

Thanks,
Mark
Thanks,
Mark