Results 1 to 4 of 4

Thread: Simple DTPicker Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Simple DTPicker Question

    Hi all,

    1) Can I set a now date for DTPicker value on the properties colunm?
    If no, cani have put DTpicker.value = now under the form_load event?

    2) What is the best approach to valid if the date1 cannot be less than date2.
    Is the below coding good enough or there is a better way.

    VB Code:
    1. If DTpicker1 > DTpicker2 Then
    2. MsgBox" You have enter an invalid date" & vbCrLf & "Please try again" , vbinformation, "Invalid Date"
    3. Cancel = true
    4. Exit sub
    5. End if
    6.  
    7. If DTpicker2 > DTpicker3 Then
    8. MsgBox" You have enter an invalid date" & vbCrLf & "Please try again" , vbinformation, "Invalid Date"
    9. Cancel = true
    10. Exit sub
    11. End if

  2. #2
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043

    Re: Simple DTPicker Question

    1 Yes on form_load

    2:
    VB Code:
    1. Private Sub DTPicker1_Change()
    2.     If DTPicker1 > DTPicker2 Then DTPicker1 = DTPicker2
    3. End Sub
    4. Private Sub DTPicker2_Change()
    5.     If DTPicker1 > DTPicker2 Then DTPicker1 = DTPicker2
    6. End Sub
    oh1mie/Vic


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Re: Simple DTPicker Question

    Hi oh1mie,

    1) yes to u can put a now date as a value under the DTPicker property? if yes, may i know where?

    If yes by putting under the form event, but whenever a click a new record, it was give a different value e.g. 12/5/05.

    2) Sorry, maybe my question isn't clear enough. I like to do a validation on the dates. Date1 is a fixed now date. Therefore date2 cannot be set less than Date1, if yes... prompt a error message to ask user to reenter.
    This condition applies to date3 too.

  4. #4
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043

    Re: Simple DTPicker Question

    Right place is Form_Load event

    VB Code:
    1. Private Sub Form_Load()
    2.     DTPicker1 = Now
    3. End Sub

    Question 2
    VB Code:
    1. Private Sub DTPicker2_Change()
    2.     If DTPicker2 < DTPicker1 Then DTPicker2 = DTPicker1
    3. End Sub
    oh1mie/Vic


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