Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default calendar date limits

how do I limit the dates that a calendar allows the user
to select? the calender is placed on a form

have tried using the 'beforeUpdate' event and can't get it
to work

using the MS Calendar Control 10.0

any ideas appreciated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default calendar date limits

Hi Brent

'Test calendar date falls within 2004

Private Sub CommandButton1_Click()
Dim calendardate As Date
Dim earliestdate As Date
Dim latestdate As Date

earliestdate = DateSerial(2004, 1, 1)
latestdate = DateSerial(2004, 12, 31)
calendardate = Calendar1.Value

If calendardate < earliestdate Or calendardate latestdate Then
MsgBox "The date selected of " & Format(calendardate, "dd mmm yyyy") & _
" does not fall between " & Format(earliestdate, "dd mmm yyyy") & _
" and " & Format(latestdate, "dd mmm yyyy") & ". Please try again."
Exit Sub
End If

MsgBox "Do your stuff here"
End Sub


--
XL2002
Regards

William



"brent" wrote in message
...
| how do I limit the dates that a calendar allows the user
| to select? the calender is placed on a form
|
| have tried using the 'beforeUpdate' event and can't get it
| to work
|
| using the MS Calendar Control 10.0
|
| any ideas appreciated


  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default calendar date limits

thanks Will

i would like to prevent user from being able to go beyond
say Jul 31 04; for example when the user selects Aug 08 04,
the calendar should reset to its' previous date and thus
the new date is not highlighted

have tried to make it work as follows -

Sub calendar1_beforeupdate(ByVal Cancel As
MSForms.ReturnBoolean)

If calender1.Value #7/31/2004# Then
Cancel = True
End If

End Sub




-----Original Message-----
Hi Brent

'Test calendar date falls within 2004

Private Sub CommandButton1_Click()
Dim calendardate As Date
Dim earliestdate As Date
Dim latestdate As Date

earliestdate = DateSerial(2004, 1, 1)
latestdate = DateSerial(2004, 12, 31)
calendardate = Calendar1.Value

If calendardate < earliestdate Or calendardate

latestdate Then
MsgBox "The date selected of " & Format(calendardate, "dd

mmm yyyy") & _
" does not fall between " & Format(earliestdate, "dd mmm

yyyy") & _
" and " & Format(latestdate, "dd mmm yyyy") & ". Please

try again."
Exit Sub
End If

MsgBox "Do your stuff here"
End Sub


--
XL2002
Regards

William



"brent" wrote in

message
...
| how do I limit the dates that a calendar allows the user
| to select? the calender is placed on a form
|
| have tried using the 'beforeUpdate' event and can't get

it
| to work
|
| using the MS Calendar Control 10.0
|
| any ideas appreciated


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default calendar date limits

Does this help?

Private Sub Calendar1_Click()
If Month(Calendar1.Value) < 7 Or Year(Calendar1.Value) < 2004 Then
MsgBox "The date selected has to fall within July 2004. Please try again."
Calendar1.Value = DateSerial(2004, 7, 1)
End If
End Sub

Private Sub UserForm_Initialize()
Calendar1.Value = DateSerial(2004, 7, 1)
End Sub


--
XL2002
Regards

William



wrote in message
...
| thanks Will
|
| i would like to prevent user from being able to go beyond
| say Jul 31 04; for example when the user selects Aug 08 04,
| the calendar should reset to its' previous date and thus
| the new date is not highlighted
|
| have tried to make it work as follows -
|
| Sub calendar1_beforeupdate(ByVal Cancel As
| MSForms.ReturnBoolean)
|
| If calender1.Value #7/31/2004# Then
| Cancel = True
| End If
|
| End Sub
|
|
|
|
| -----Original Message-----
| Hi Brent
|
| 'Test calendar date falls within 2004
|
| Private Sub CommandButton1_Click()
| Dim calendardate As Date
| Dim earliestdate As Date
| Dim latestdate As Date
|
| earliestdate = DateSerial(2004, 1, 1)
| latestdate = DateSerial(2004, 12, 31)
| calendardate = Calendar1.Value
|
| If calendardate < earliestdate Or calendardate
| latestdate Then
| MsgBox "The date selected of " & Format(calendardate, "dd
| mmm yyyy") & _
| " does not fall between " & Format(earliestdate, "dd mmm
| yyyy") & _
| " and " & Format(latestdate, "dd mmm yyyy") & ". Please
| try again."
| Exit Sub
| End If
|
| MsgBox "Do your stuff here"
| End Sub
|
|
| --
| XL2002
| Regards
|
| William
|
|
|
| "brent" wrote in
| message
| ...
| | how do I limit the dates that a calendar allows the user
| | to select? the calender is placed on a form
| |
| | have tried using the 'beforeUpdate' event and can't get
| it
| | to work
| |
| | using the MS Calendar Control 10.0
| |
| | any ideas appreciated
|
|
| .
|


  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default calendar date limits

William,

that is very helpful!

I would like to go a step further though and obtain the
date that was selected prior to the update

i.e. - if the date with focus is July 7 04 then upon
trying an "Aug' date, the focus is returned to Jul 07
again.

have tried to capture the value with beforeUpdate but
at runtime the procedure does not seem to get cycled using
the example below

thanks for your help again



-----Original Message-----
Does this help?

Private Sub Calendar1_Click()
If Month(Calendar1.Value) < 7 Or Year(Calendar1.Value)

< 2004 Then
MsgBox "The date selected has to fall within July 2004.

Please try again."
Calendar1.Value = DateSerial(2004, 7, 1)
End If
End Sub

Private Sub UserForm_Initialize()
Calendar1.Value = DateSerial(2004, 7, 1)
End Sub


--
XL2002
Regards

William



wrote in message
...
| thanks Will
|
| i would like to prevent user from being able to go

beyond
| say Jul 31 04; for example when the user selects Aug 08

04,
| the calendar should reset to its' previous date and thus
| the new date is not highlighted
|
| have tried to make it work as follows -
|
| Sub calendar1_beforeupdate(ByVal Cancel As
| MSForms.ReturnBoolean)
|
| If calender1.Value #7/31/2004# Then
| Cancel = True
| End If
|
| End Sub
|
|
|
|
| -----Original Message-----
| Hi Brent
|
| 'Test calendar date falls within 2004
|
| Private Sub CommandButton1_Click()
| Dim calendardate As Date
| Dim earliestdate As Date
| Dim latestdate As Date
|
| earliestdate = DateSerial(2004, 1, 1)
| latestdate = DateSerial(2004, 12, 31)
| calendardate = Calendar1.Value
|
| If calendardate < earliestdate Or calendardate
| latestdate Then
| MsgBox "The date selected of " & Format

(calendardate, "dd
| mmm yyyy") & _
| " does not fall between " & Format(earliestdate, "dd

mmm
| yyyy") & _
| " and " & Format(latestdate, "dd mmm yyyy") & ". Please
| try again."
| Exit Sub
| End If
|
| MsgBox "Do your stuff here"
| End Sub
|
|
| --
| XL2002
| Regards
|
| William
|
|
|
| "brent" wrote in
| message
| ...
| | how do I limit the dates that a calendar allows the

user
| | to select? the calender is placed on a form
| |
| | have tried using the 'beforeUpdate' event and can't

get
| it
| | to work
| |
| | using the MS Calendar Control 10.0
| |
| | any ideas appreciated
|
|
| .
|


.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default calendar date limits

Hi

This should stop any change to the month or year

Private Sub Calendar1_NewMonth()
Calendar1.Value = Calendar1.Value
End Sub

Private Sub Calendar1_NewYear()
Calendar1.Value = Calendar1.Value
End Sub

Private Sub UserForm_Initialize()
Calendar1.Value = DateSerial(2004, 7, 1)
End Sub


--
XL2002
Regards

William



wrote in message
...
| William,
|
| that is very helpful!
|
| I would like to go a step further though and obtain the
| date that was selected prior to the update
|
| i.e. - if the date with focus is July 7 04 then upon
| trying an "Aug' date, the focus is returned to Jul 07
| again.
|
| have tried to capture the value with beforeUpdate but
| at runtime the procedure does not seem to get cycled using
| the example below
|
| thanks for your help again
|
|
|
| -----Original Message-----
| Does this help?
|
| Private Sub Calendar1_Click()
| If Month(Calendar1.Value) < 7 Or Year(Calendar1.Value)
| < 2004 Then
| MsgBox "The date selected has to fall within July 2004.
| Please try again."
| Calendar1.Value = DateSerial(2004, 7, 1)
| End If
| End Sub
|
| Private Sub UserForm_Initialize()
| Calendar1.Value = DateSerial(2004, 7, 1)
| End Sub
|
|
| --
| XL2002
| Regards
|
| William
|
|
|
| wrote in message
| ...
| | thanks Will
| |
| | i would like to prevent user from being able to go
| beyond
| | say Jul 31 04; for example when the user selects Aug 08
| 04,
| | the calendar should reset to its' previous date and thus
| | the new date is not highlighted
| |
| | have tried to make it work as follows -
| |
| | Sub calendar1_beforeupdate(ByVal Cancel As
| | MSForms.ReturnBoolean)
| |
| | If calender1.Value #7/31/2004# Then
| | Cancel = True
| | End If
| |
| | End Sub
| |
| |
| |
| |
| | -----Original Message-----
| | Hi Brent
| |
| | 'Test calendar date falls within 2004
| |
| | Private Sub CommandButton1_Click()
| | Dim calendardate As Date
| | Dim earliestdate As Date
| | Dim latestdate As Date
| |
| | earliestdate = DateSerial(2004, 1, 1)
| | latestdate = DateSerial(2004, 12, 31)
| | calendardate = Calendar1.Value
| |
| | If calendardate < earliestdate Or calendardate
| | latestdate Then
| | MsgBox "The date selected of " & Format
| (calendardate, "dd
| | mmm yyyy") & _
| | " does not fall between " & Format(earliestdate, "dd
| mmm
| | yyyy") & _
| | " and " & Format(latestdate, "dd mmm yyyy") & ". Please
| | try again."
| | Exit Sub
| | End If
| |
| | MsgBox "Do your stuff here"
| | End Sub
| |
| |
| | --
| | XL2002
| | Regards
| |
| | William
| |
| |
| |
| | "brent" wrote in
| | message
| | ...
| | | how do I limit the dates that a calendar allows the
| user
| | | to select? the calender is placed on a form
| | |
| | | have tried using the 'beforeUpdate' event and can't
| get
| | it
| | | to work
| | |
| | | using the MS Calendar Control 10.0
| | |
| | | any ideas appreciated
| |
| |
| | .
| |
|
|
| .
|


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert date from Gregorian Calendar to Hijri Calendar H.Alkhodary Excel Discussion (Misc queries) 1 February 21st 09 10:11 AM
How to Convert a Julian Date to Calendar Date Rob Phillips Excel Discussion (Misc queries) 2 December 5th 07 05:46 PM
How to link an Excel file due date to Outlook calendar date? anok New Users to Excel 0 May 9th 07 09:31 PM
have a date cell pop up a monthly calendar to choose a date lillywhite Excel Worksheet Functions 4 August 21st 05 09:14 PM
how to convert julian date to regular calendar date Ron Excel Worksheet Functions 5 May 5th 05 11:05 PM


All times are GMT +1. The time now is 12:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"