Comments inline...
--
Ken Snell
<MS ACCESS MVP>
Ben said:
Wow - thank you so much for the handholding, I got it working!!!
Now, if you'll indulge me, two more questions:
1.. To make the date merge into my letters in a given format, should I
alter the code in the query (I'm not sure how to do this), or the merge
field in Word (which I know how to do).
I have not worked with merging into Word, so my answer may be completely
wrong. However, if the field in Word is just expecting a text string, then
you can wrap the expression with the Format function to specify how to
export the date -- for example, to get "January 1, 2004" format:
MeetingDate: Format(DateSerial(Year(Date()), [MeetingMonth], 8 -
DatePart("w",
DateSerial(Year(Date()), [MeetingMonth], 1), 1 + [MeetingWeekDay] Mod 7) +
([MeetingWeekNum] - 1) * 7), "mmmm dd, yyyy")
2.. Is there a way to have it convert the second Monday in December for
LAST year and NEXT year? How do you tweak the code to do that? In
December, I need to be able to calculate the meeting date for January of the
next year, and in January I need to be able to send out a letter referencing
the meeting that was held in December of the previous year.
This field can calculate only one value; it cannot give you two. However,
you can put a second calculated field in the query that will give you the
other date. So, for example, let's have two calculated fields, one for the
next meeting date, and one for the previous meeting date:
NextMeetingDate: Format(DateSerial(Year(Date() - (Month(Date())=12)),
[MeetingMonth], 8 - DatePart("w",
DateSerial(Year(Date()), [MeetingMonth], 1), 1 + [MeetingWeekDay] Mod 7) +
([MeetingWeekNum] - 1) * 7), "mmmm dd, yyyy")
PreviousMeetingDate: Format(DateSerial(Year(Date() + (Month(Date())=1)),
[MeetingMonth], 8 - DatePart("w",
DateSerial(Year(Date()), [MeetingMonth], 1), 1 + [MeetingWeekDay] Mod 7) +
([MeetingWeekNum] - 1) * 7), "mmmm dd, yyyy")
The above fields use a boolean expression (e.g., Month(Date())=12 ) to
return a True or False. True in ACCESS is the integer value of -1 (negative
1). So, for a December date, the expression adds 1 to the year value. The
other one uses similar expression to subtract one from the year value.