473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 3862
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 with the functions provided by the built-in...
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 with dates for shipment, ETA etc. Each one of these...
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 and below the cursor position. I hunted through...
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 monthcalendar checks this, the form where the monhcalendar is...
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 form with the monthcalendar: Private Sub...
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: "SelectionRange: Start: 5/5/2005 12:00:00 AM, End: 5/5/2005...
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 booked? TIA - Ray
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 Monday - Sunday. I thought that using AddBoldedDate...
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, but also if they click on the Previous or Next...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.