Hi,
This is my code I wrote which was used in conjunction with code I obtained from this forum:
My Code [Modify to your requirements]
=========
BEGIN CODE
=========
Dim LastWorkDayOfMonth As Date 'Declare LastWorkDayOfMonth variable
LastWorkDayOfMonth = LastWorkDay() 'Assign the value of LastWorkDay to the LastWorkDayOfMonth variable
'If the current date ie equal to the LastWork Day Of The Month then
If LastWorkDayOfMonth = Date Then
'Print the Monthly Letter Type Chart
DoCmd.OpenReport "rptChartMonthlyLetterCount", acNormal, "", ""
DoCmd.OpenReport "rptStatsMonth", acNormal, "", ""
'Append Monthly data to tblCommercial table
DoCmd.OpenQuery "qryAppCommercial", acNormal, acEdit
'Export the contents of the tblCommercial table to the Commerical folder on the Question on 'Leint03' drive with the current date
DoCmd.TransferText acExportFixed, "CommercialExportSpec", "tblCommercial", "E:\Commercial\Commercial" & "_" & Format(Date, "ddmmyy") & ".txt", False, ""
'Delete the data from the tblCommercial table
DoCmd.OpenQuery "qryDelCommercial", acNormal, acEdit
End If
=========
END CODE
=========
Code obtained from this forum, for use with the above
=========
BEGIN CODE
=========
Public Function LastWorkDay() As Date
'-- Return the last working day of the current month
Dim Searching As Boolean
Searching = True
LastWorkDay = DateSerial(Year(Date), Month(Date) + 1, 0) '-- Start at the last day of the month
Do While Searching
If Weekday(LastWorkDay, vbMonday) > 5 Then
'-- Weekend day, back up a day
LastWorkDay = LastWorkDay - 1
Else
'-- If you have a Holiday Table then enable the next IF...Else
' If Weekday(LastWorkday, vbMonday) > 5 Or _
Not IsNull(DLookup("[HoliDate]", "tblHolidays", _
"[HoliDate] = " & Format(LastWorkday, "\#mm\/dd\/yyyy\#;;;\N\u\l\l"))) Then
'-- The above Format of LastWorkday works with US or UK dates!
' LastWorkday = LastWorkday - 1
' Else
'-- The search is over
Searching = False
End If
Loop
End Function
=========
END CODE
=========
I hope this helps
John