Last Monday of the Month

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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
 
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
 
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
(e-mail address removed)
www.pcdatasheet.com
 
Back
Top