472,331 Members | 1,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 software developers and data experts.

Week Numbers in Stephan Leban's MonthCalendar

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
10 3749
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Laguna | last post by:
Hi Gurus, I want to find the expiration date of stock options (3rd Friday of the month) for an any give month and year. I have tried a few tricks...
2
by: Simon Pleasants | last post by:
I recently built a database to help keep track of shipments we are bringing into the country. Included in the database are a number of fields...
16
by: DFS | last post by:
If you're listening, I want the middle of the calendar (showing 1 month) to open below the cursor position. It currently opens just to the right...
13
by: steven | last post by:
A monthcalendar checks every 2 minutes if theres a new day. Does anyone knows how to disable this ? The problem is that, everytime a...
0
by: steven | last post by:
Start a new project with 2 forms: one with a datagrid, a button and a monthcalendar, and another form without controls. Try this code in your...
8
by: vbmark | last post by:
I want the MonthCalendar control to return the single day selected. I have MaxSelectionCount = 1. What I get back though is this: ...
1
by: Chesne | last post by:
Does anyone know if it is possible to link Leban's Calendar to a table so that when it is activated it will show previous dates which have been...
5
by: Randy | last post by:
Based on the date that the user selects, I'm trying to make the MonthCalendar control highlight the entire week. In my case, the week is from...
11
by: Randy | last post by:
I have a MonthCalendar on one of my forms. I have disovered that the DateChanged event is triggered not only when the user clicks on a new date,...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.