By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,644 Members | 2,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,644 IT Pros & Developers. It's quick & easy.

Week Numbers in Stephan Leban's MonthCalendar

P: n/a
I noticed that the week numbers in Stephan Leban's MonthCalendar are not consistent with Microsoft Outlook (they are shifted one week forward). Is there any way I can sync these two up by changing something in the module or the code in Stephan's MonthCalendar?
Thanks,
TySmith

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Hi Ty,
the class currently does not expose theSetFirstDayOfTheWeek property. If
this is the property you require let me know and I'll post some code for
you to add to the class.
Here is the info from MSDN.
MCM_SETFIRSTDAYOFWEEK Message

------------------------------------------------------------------------
--------

Sets the first day of the week for a month calendar control. You can
send this message explicitly or by using the MonthCal_SetFirstDayOfWeek
macro.

Syntax
To send this message, call the SendMessage function as follows.
lResult = SendMessage( // returns LRESULT in lResult (HWND)
hWndControl, // handle to destination control (UINT)
MCM_SETFIRSTDAYOFWEEK, // message ID (WPARAM) wParam, // =
0; not used, must be zero (LPARAM) lParam // = (LPARAM) (INT)
iDay; );
Parameters

wParam
Must be zero.
iDay
Value of type int representing which day is to be set as the first day
of the week. This value must be one of the day numbers.
Return Value

Returns a DWORD value that contains two values. The high word is a BOOL
value that is nonzero if the previous first day of the week did not
equal LOCALE_IFIRSTDAYOFWEEK, or zero otherwise. The low word is an INT
value that represents the previous first day of the week.
Remarks

If the first day of the week is set to anything other than the default
(LOCALE_IFIRSTDAYOFWEEK), the control will not automatically update
first-day-of-the-week changes based on locale changes.
Month Calendar Day Numbers

------------------------------------------------------------------------
--------

This section lists the numeric representations of the days of the week
used by the month calendar control.

Constants

Value
Day of Week

0
Monday

1
Tuesday

2
Wednesday

3
Thursday

4
Friday

5
Saturday

6
Sunday

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Ty Smith via AccessMonster.com" <fo***@AccessMonster.com> wrote in
message news:17******************************@AccessMonste r.com...
I noticed that the week numbers in Stephan Leban's MonthCalendar are not consistent with Microsoft Outlook (they are shifted one week
forward). Is there any way I can sync these two up by changing
something in the module or the code in Stephan's MonthCalendar? Thanks,
TySmith

--
Message posted via http://www.accessmonster.com


Nov 13 '05 #2

P: n/a
I just had a peek at the Calendar config options In MS OUtlook.
To have my MonthCalendar synch up week swith Outlook's you would have
to:
Menu -> Tools-Options.
Select Calendar Options.
Change First Week of year to "First 4 day week"

The Microsoft MonthCalendar common control notes:
MCS_WEEKNUMBERS
Version 4.70. The month calendar control will display week numbers
(1-52) to the left of each row of days. Week 1 is defined as the first
week that contains at least four days.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Ty Smith via AccessMonster.com" <fo***@AccessMonster.com> wrote in
message news:17******************************@AccessMonste r.com...
I noticed that the week numbers in Stephan Leban's MonthCalendar are not consistent with Microsoft Outlook (they are shifted one week
forward). Is there any way I can sync these two up by changing
something in the module or the code in Stephan's MonthCalendar? Thanks,
TySmith

--
Message posted via http://www.accessmonster.com


Nov 13 '05 #3

P: n/a
Stephan,
Your information is OUTSTANDING! I looked up the ISO 8601 standard and I can change my system to accomodate this standard. Thank you for your assistance. Maybe you may want to consider these various options in your next revision of your robust MonthCalendar.
Thanks,
TySmith

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #4

P: n/a
Stephan,
After further review, the week numbering system in Access is not ISO standards and is not consistent with your calendar and the stardard system has a glitch.

If I run these queries, Access returns:
DatePart("ww",#12/31/2004#) ---> Week 53
DatePart("ww",#1/1/2005#) ---> Week 1
DatePart("ww",#1/2/2005#) ---> Week 2

I would like to use ISO standards, but could not find a simple ISOWEEK function anywhere for Access. How did you calculate this for your calendar? Do you have a simple function?
Thanks again,
TySmith

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #5

P: n/a
Ty there is not much I can do to help you with this issue. It's not my
Calendar it is the Microsoft MonthCalendar instantiated directly from
the Microsoft Common Controls DLL.

1) Try starting a new thread on this ISO standards issue.

2) Search GoogleGroups for all Access NGs and "ISO Date"

http://groups.google.com/groups?as_q...=images&as_ugr
oup=*access*&lr=&num=100&hl=en

The very first hit gives a very long thread with several solutions to
calculate the ISO weeknumber.
http://groups.google.com/groups?hl=e...46oe%241%40new
s.wave.co.nz&rnum=1&prev=/groups%3Fas_q%3D%2522ISO%2520date%2522%26safe%
3Dimages%26as_ugroup%3D*access*%26lr%3D%26num%3D10 0%26hl%3Den
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Ty Smith via AccessMonster.com" <fo***@AccessMonster.com> wrote in
message news:5c******************************@AccessMonste r.com...
Stephan,
After further review, the week numbering system in Access is not ISO standards and is not consistent with your calendar and the stardard
system has a glitch.
If I run these queries, Access returns:
DatePart("ww",#12/31/2004#) ---> Week 53
DatePart("ww",#1/1/2005#) ---> Week 1
DatePart("ww",#1/2/2005#) ---> Week 2

I would like to use ISO standards, but could not find a simple ISOWEEK function anywhere for Access. How did you calculate this for your
calendar? Do you have a simple function? Thanks again,
TySmith

--
Message posted via http://www.accessmonster.com


Nov 13 '05 #6

P: n/a
Stephan,

Thanks for pointing me in the right direction. After further research, I found a great VBA function that computes ISO week numbers. It was written by John Green, one of the Excel MVPs.

Function ISOWeekNum(TheDate As Date, Optional NumFormat As Long = 1) As Long
Dim y As Long
Dim YearStart As Date
Dim NextYearStart As Date
Dim N As Long

y = Year(TheDate)
YearStart = ISOYearStart(y)
NextYearStart = ISOYearStart(y + 1)
If TheDate >= NextYearStart Then 'end of December
y = y + 1
YearStart = NextYearStart
ElseIf TheDate < YearStart Then 'early January
y = y - 1
YearStart = ISOYearStart(y)
End If
N = (TheDate - YearStart) \ 7 + 1

Select Case NumFormat
Case 1: ISOWeekNum = N
Case 2: ISOWeekNum = (y Mod 100) * 100 + N
Case 3: ISOWeekNum = y * 100 + N
End Select
End Function

Function ISOYearStart(TheYear As Long) As Date
Dim Jan4 As Date

Jan4 = DateSerial(TheYear, 1, 4)
'Start week on Monday
' ISOYearStart = Jan4 - Weekday(Jan4, vbMonday) + 1
'Start week on Sunday
ISOYearStart = Jan4 - Weekday(Jan4, vbSunday) + 1
End Function

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #7

P: n/a
Glad you have found a resolution and thanks for posting it here!
:-)

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Ty Smith via AccessMonster.com" <fo***@AccessMonster.com> wrote in
message news:18******************************@AccessMonste r.com...
Stephan,

Thanks for pointing me in the right direction. After further research, I found a great VBA function that computes ISO week numbers.
It was written by John Green, one of the Excel MVPs.
Function ISOWeekNum(TheDate As Date, Optional NumFormat As Long = 1) As Long Dim y As Long
Dim YearStart As Date
Dim NextYearStart As Date
Dim N As Long

y = Year(TheDate)
YearStart = ISOYearStart(y)
NextYearStart = ISOYearStart(y + 1)
If TheDate >= NextYearStart Then 'end of December
y = y + 1
YearStart = NextYearStart
ElseIf TheDate < YearStart Then 'early January
y = y - 1
YearStart = ISOYearStart(y)
End If
N = (TheDate - YearStart) \ 7 + 1

Select Case NumFormat
Case 1: ISOWeekNum = N
Case 2: ISOWeekNum = (y Mod 100) * 100 + N
Case 3: ISOWeekNum = y * 100 + N
End Select
End Function

Function ISOYearStart(TheYear As Long) As Date
Dim Jan4 As Date

Jan4 = DateSerial(TheYear, 1, 4)
'Start week on Monday
' ISOYearStart = Jan4 - Weekday(Jan4, vbMonday) + 1
'Start week on Sunday
ISOYearStart = Jan4 - Weekday(Jan4, vbSunday) + 1
End Function

--
Message posted via http://www.accessmonster.com


Nov 13 '05 #8

P: n/a
Stephen,
Your calendar seems to update the field without a trace. How do you run an event on the exit or after the field populates? I tried, After Update, Before Update, On Change, On Exit and none of them seem to work. I even tried to use a Call in the code and that definitely doesn't work. Any suggestions?
Ty

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #9

P: n/a
Ty the ShowMonthCalendar function simply returns the date selected by
the User. It is up to you to then decide whether you want to update the
field or not.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Ty Smith via AccessMonster.com" <fo***@AccessMonster.com> wrote in
message news:ab******************************@AccessMonste r.com...
Stephen,
Your calendar seems to update the field without a trace. How do you run an event on the exit or after the field populates? I tried, After
Update, Before Update, On Change, On Exit and none of them seem to work.
I even tried to use a Call in the code and that definitely doesn't work.
Any suggestions? Ty

--
Message posted via http://www.accessmonster.com


Nov 13 '05 #10

P: n/a
Ty I just had a quick peek at the code behind the sample form in the
MonthCalendar MDB you downloaded. It does use a local variable to hold
the date returned from the Calendar function which is then used to
update the bound TextBox control.
Not quite sure why you are having an issue here...

Stephen Lebans
www.lebans.com

Stephen Lebans wrote:
Ty the ShowMonthCalendar function simply returns the date selected by
the User. It is up to you to then decide whether you want to update the field or not.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Ty Smith via AccessMonster.com" <fo***@AccessMonster.com> wrote in
message news:ab******************************@AccessMonste r.com...
Stephen,
Your calendar seems to update the field without a trace. How do
you run an event on the exit or after the field populates? I tried, After Update, Before Update, On Change, On Exit and none of them seem to work. I even tried to use a Call in the code and that definitely doesn't work. Any suggestions?
Ty

--
Message posted via http://www.accessmonster.com


Nov 13 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.