|
Q: George Forsythe writes: "I want to insert a field in a Word document that calculates Tomorrow's date. It would be even better if I could make it Next Weekday's date. There seems to be no intuitively obvious way to do this."
A: This is easy enough when writing data to a Word document from Access; just use DateAdd("d", 1, Date()) to get tomorrow's date, and write it to a Word doc property (I like to use Text properties and format the results with field switches, to avoid having to enter a default value).
For the next weekday, use code like the following:
Public Function NextWeekday(dteTest) As Date
Dim dteTestDate As Date
Dim n As Integer
dteTestDate = dteTest
If Weekday(dteTestDate) <> vbSaturday And Weekday(dteTestDate) _
<> vbSunday Then
NextWeekday = dteTestDate
Else
For n = 1 To 7
dteTestDate = DateAdd("d", n, dteTest)
If Weekday(dteTestDate) <> vbSaturday And _
Weekday(dteTestDate) <> vbSunday Then
NextWeekday = dteTestDate
Exit Function
End If
Next n
End If
End Function
Article posted: Tuesday, 27 May 2008
there's more ...
If you liked this article you'll LOVE our new ebooks.
 |
Windows 8 for Microsoft Office users A practical guide the new, changed and unfamiliar in Windows 8
A focused and unvarnished look at Windows 8, especially written for
the many people who use Microsoft Office Get it today
- click here.
|
ORGANIZING OUTLOOK EMAIL - tame your Outlook 2010 Inbox
100+ pages of practical tips and help to streamline,
automate and search your Inbox. Get more
than you ever thought possible from Outlook. Read it today
- click here.
|