ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Restricting use of Calendar Control (https://www.excelbanter.com/excel-programming/357527-restricting-use-calendar-control.html)

Patrick Simonds

Restricting use of Calendar Control
 
I asked this question a couple of days ago and got a response (but the
response while it would work, did not fit into how I wanted to set up my
form) so I thought I would try one more time:

Is there any way to lock a Calendar control in such a way that someone could
only select a Thursday? Ideally the last Thursday of the month.



Patrick Simonds

Restricting use of Calendar Control
 
Worked out my own solution. My not look pretty, but it works:

Private Sub Calendar1_Click()

Dim MyDate, MyWeekDay
MyDate = Calendar1.Value ' Assign a date.

MyWeekDay = Weekday(MyDate)

If MyWeekDay = 5 Then

Exit Sub

End If
Unload Calendar
WrongDay.Show
End Sub


"Patrick Simonds" wrote in message
...
I asked this question a couple of days ago and got a response (but the
response while it would work, did not fit into how I wanted to set up my
form) so I thought I would try one more time:

Is there any way to lock a Calendar control in such a way that someone
could only select a Thursday? Ideally the last Thursday of the month.





Jim Cone

Restricting use of Calendar Control
 
Another approach would be to use a list box with only the last
Thursday of each month listed.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Patrick Simonds"
wrote in message
...
I asked this question a couple of days ago and got a response (but the
response while it would work, did not fit into how I wanted to set up my
form) so I thought I would try one more time:

Is there any way to lock a Calendar control in such a way that someone could
only select a Thursday? Ideally the last Thursday of the month.



NickHK

Restricting use of Calendar Control
 
Patrick,
This any better ?
Private Sub Calendar1_Click()
With Calendar1
'Is it any Thursday
If Weekday(.Value) = vbThursday Then
'Is it the last Thursday
If Month(.Value) = Month(.Value + 7) Then
'Same month so cannot be last Thursday
MsgBox "Not last Thursday in this month"
Else
MsgBox "Date OK"
End If
Else
MsgBox "Not a Thurday"
End If
End With
End Sub

NickHK

"Patrick Simonds" wrote in message
...
Worked out my own solution. My not look pretty, but it works:

Private Sub Calendar1_Click()

Dim MyDate, MyWeekDay
MyDate = Calendar1.Value ' Assign a date.

MyWeekDay = Weekday(MyDate)

If MyWeekDay = 5 Then

Exit Sub

End If
Unload Calendar
WrongDay.Show
End Sub


"Patrick Simonds" wrote in message
...
I asked this question a couple of days ago and got a response (but the
response while it would work, did not fit into how I wanted to set up my
form) so I thought I would try one more time:

Is there any way to lock a Calendar control in such a way that someone
could only select a Thursday? Ideally the last Thursday of the month.







NickHK

Restricting use of Calendar Control
 
Patrick,
Jim's solution is probably better.
I find it frustrating when I am apparently given the choice of all these
options, but for some unknown reason cannot choose them.
Why give the user all the days of the month if only a single day is valid ?

NickHK

"Jim Cone" wrote in message
...
Another approach would be to use a list box with only the last
Thursday of each month listed.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Patrick Simonds"
wrote in message
...
I asked this question a couple of days ago and got a response (but the
response while it would work, did not fit into how I wanted to set up my
form) so I thought I would try one more time:

Is there any way to lock a Calendar control in such a way that someone

could
only select a Thursday? Ideally the last Thursday of the month.






All times are GMT +1. The time now is 05:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com