Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Date Interval 1

Status
Not open for further replies.

ghacig

Technical User
Sep 24, 2004
60
US
Hi

I have an unbound form that contains two unbound controls, DateFrom and DateTo. The idea is to select two dates.

I was wondering if there is a way and I can have a command button called cmdWeek. When the user clicks it, the two controls will be populated automatically with the dates corresponding to Monday and Sunday of the current week.

I would appreciate any help.
 
Do you mean:

Code:
If Weekday(Date) = 1 Then
    AddSun = 1
Else
    AddSun = 8
End If

dMonday = Date - Weekday(Date, vbSunday) + 2
dSunday = Date - Weekday(Date, vbSunday) + AddSun


 
Remou, why not simply this ?
dMonday = Date - Weekday(Date, vbSunday) + 2
dSunday = dMonday + 6

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks guys. I am a little confused. What does this return?

Weekday(Date,vbSunday)

Of course I can do something like:

Select Case Weekday(Date)
case 1
DMonday = Weekday(Date +1)
Case 2
DMonday Weekday(Date)
etc...

Thanks.
 
OK, I figured it out. This works.

Select Case Weekday(Date)

Case 1

Me.DMonday = Date + 1
Case 2
Me.DMonday = Date
Case 3
Me.DMonday = Date - 1
Case 4
Me.DMonday = Date - 2
Case 5
Me.DMonday = Date - 3
Case 6
Me.DMonday = Date - 4
Case 7
Me.DMonday = Date - 5

End Select

 
PHV and Remou,

Code works great. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top