-
Nov 6th, 2008, 06:24 AM
#1
Thread Starter
New Member
Calenders Help!
So...i can put a calender on a form and do the code to allow you select a start date, end date, and calculate the amount of days you are staying somewhere.
But for my project i have to restrict the calender so that the customer cannot enter a date that has already expired...but i dont have a clue how to do this!
Ny ideas??!!
-
Nov 6th, 2008, 07:48 AM
#2
Re: Calenders Help!
Two assumptions:
1. You are using the MonthView not the Calendar control.
2. By "expired" you mean in the past.
If so, try this
Code:
Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
If DateClicked < Format(Now, "mm/dd/yyyy") Then
MsgBox "Invalid Date. Can not be earlier than today."
Else
Text1.Text = DateClicked
End If
End Sub
-
Nov 6th, 2008, 07:51 AM
#3
Re: Calenders Help!
Originally Posted by emeros89
So...i can put a calender on a form and do the code to allow you select a start date, end date, and calculate the amount of days you are staying somewhere.
But for my project i have to restrict the calender so that the customer cannot enter a date that has already expired...but i dont have a clue how to do this!
Ny ideas??!!
I don't know what kind of calendar control you are using and what you mean by "expired" date. I just threw this together for a month view but it should work on what you are doing.
In the GotFocus capture the date currently displayed. On the click event check it and put it back to what it was.
Code:
Option Explicit
Private dMonthViewValue As Date
Private Sub Form_Load()
'MonthView.Value = What ever it needs to be to start.
End Sub
Private Sub MonthView_DateClick(ByVal DateClicked As Date)
If Format(MonthView.Value, "YYYYMMDD") < Format(Now(), "YYYYMMDD") Then
MsgBox "Can't use prior date"
MonthView.Value = dMonthViewValue
End If
End Sub
Private Sub MonthView_GotFocus()
dMonthViewValue = MonthView.Value
End Sub
-
Nov 6th, 2008, 07:58 AM
#4
Thread Starter
New Member
Re: Calenders Help!
Thanks well, is its the Microsoft Calendar Control 12.0,
Sorry, by expired i meant dates already past so if today is nov. 6th then you cant choose Nov. 5th / 4th etc
-
Nov 6th, 2008, 08:07 AM
#5
Re: Calenders Help!
What I posted should work for you then.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|