Results 1 to 5 of 5

Thread: DTPicker checkbox event

  1. #1

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Resolved DTPicker checkbox event

    I'm using a DTPicker in my project. I want to set its value to today when the user changes the DTPicker's checkbox from unchecked to checked. I'm not binding it to any data - its just standalone.

    I don't have a problem with setting the date to today, but I can't find a way of telling when the user has changed the checkbox to checked. The _Click event is no good because this fires when the dd/mm/yy section is clicked as well.

    Can anyone help?
    Last edited by trisuglow; Jan 31st, 2005 at 11:45 AM.
    This world is not my home. I'm just passing through.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: DTPicker checkbox event

    When the CheckBox is unchecked the Value property becomes Null, so the Click event can still be used.

    VB Code:
    1. Private Sub DTPicker1_Click()
    2.     If IsNull(DTPicker1.Value) Then
    3.         DTPicker1.Value = Now
    4.         DTPicker1.Value = Null
    5.     End If
    6. End Sub

  3. #3

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: DTPicker checkbox event

    Thanks, but this doesn't work for me. I don't want the date to be set to today when the user unchecks the box, only when they check it.

    Any further thoughts?
    This world is not my home. I'm just passing through.

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: DTPicker checkbox event

    Put the above code in the MouseDown event of the DatePicker.

  5. #5

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: DTPicker checkbox event

    Good solution Bruce. Thanks.
    This world is not my home. I'm just passing through.

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