Results 1 to 4 of 4

Thread: DTPicker Question?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    269

    DTPicker Question?

    Hi,

    In a form, I have a field that use DTPicker to let user select the date. How can I prevent the user pick the weekend (like sat, sun).

    Thanks!

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

    Re: DTPicker Question?

    Code:
        If Weekday(Text1.Text) = vbSunday Or Weekday(Text1.Text) = vbSaturday Then
           MsgBox "The Date cannot be a Saturday or Sunday.", vbOKOnly + vbExclamation, "Invalid Date"
           Text1.Text = vbNullString
           Exit Sub
        End If

  3. #3
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: DTPicker Question?

    Code:
        If Weekday(dtPicker.Value) = vbSunday Or Weekday(dtPicker.Value) = vbSaturday Then
           MsgBox "The Date cannot be a Saturday or Sunday.", vbOKOnly + vbExclamation, "Invalid Date"
           dtPicker.Value = now()
           Exit Sub
        End If
    Just modified Hack's to use the dtpicker. :P

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

    Re: DTPicker Question?

    Quote Originally Posted by Besoup
    Code:
        If Weekday(dtPicker.Value) = vbSunday Or Weekday(dtPicker.Value) = vbSaturday Then
           MsgBox "The Date cannot be a Saturday or Sunday.", vbOKOnly + vbExclamation, "Invalid Date"
           dtPicker.Value = now()
           Exit Sub
        End If
    Just modified Hack's to use the dtpicker. :P
    That was actually taken directly from one of my projects in which I use a dtpicker.

    I changed the control names to make it more generic, but I think I generized it a bit too much.

    Takes Besoup!

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