Last Monday of the Month

R

Redwing4

Programmically, is there a way to program Access check if the date is the
last Monday of the month? I thought about creating a date table with the
last Monday of the month and have Access run the query if the current date is
in the table, but this may require user maintenance. Any ideas?
 
P

PC Datasheet

Put the following code in a standard function:

Use the following code to check if YourDate is the last Monday of the
current month:If Me!YourDate = LastXDay(Date(), vbMonday) Then

Public Function LastXDay(dtD As Date, DayConst As Integer) As Date
LastXDay = DateSerial(Year(dtD), Month(dtD) + 1, _
(-WeekDay(DateSerial(Year(dtD), _
Month(dtD) + 1, 1), 2) + DayConst - 7) Mod 7)
End Function
 
M

Mauricio Silva

Try This:

Function IsLastMonday(aDate As Date) As Boolean
IsLastMonday = (Weekday(aDate, vbMonday) = 1) And (Month(aDate + 7) <>
Month(aDate))
End Function

First it verifies if it is a monday and then verify if the (date + 7) is a
diferent month

Take care

Mauricio Silva
 
P

PC Datasheet

oops ---

I accidently sent this before inishing my response...

Put the following code in a standard function:

Public Function LastXDay(dtD As Date, DayConst As Integer) As Date
LastXDay = DateSerial(Year(dtD), Month(dtD) + 1, _
(-WeekDay(DateSerial(Year(dtD), _
Month(dtD) + 1, 1), 2) + DayConst - 7) Mod 7)
End Function

Use the following code to check if YourDate is the last Monday of the
current month:
If Me!YourDate = LastXDay(Date(), vbMonday) Then
Msgbox "YourDate is the last Monday of the current month"
End If


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
[email protected]
www.pcdatasheet.com
 
Top