Results 1 to 5 of 5

Thread: Calenders Help!

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    5

    Thumbs up 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??!!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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

  3. #3
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: Calenders Help!

    Quote 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

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    5

    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

  5. #5
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    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
  •  



Click Here to Expand Forum to Full Width