DTPicker 's checkbox

AlexMD
AlexMD used Ask the Experts™
on
Hi I have a DTPicker in my program but i am not sure one of its property: Checkbox.
When I put true there a check box will appear otherwise, there is not box at all.
My question is that I wanna check at run time if the checkbox has been marked, How do i do that? I am sure it can be done, but I am just lost....
Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
I'm not sure, but it seems that when this is checked, the date shows up in the .Value property; if unchecked, the .Value property is Null.

>I wanna check at run time if the checkbox has been marked

If DTPicker.Value is null and DTPicker.CheckBox = True then
  msgbox "picker is unchecked"
else
  msgbox "picker is checked"
endif

Author

Commented:
thanks,rspahitz .
But I tried this way for somereason, the message box will never show up. I watched the values, but it seems that the values are there(since I put the value in property box), but it just did not seems to be working. Also while I type ".", it shows 'Value' but finally in the screen it is 'value'. There must be something wrong...
ANy idea?

Commented:
I don't proclaim to be a DTP expert.  I hadn't even known about the checkbox property.

After observation on my system, I see that unchecked the item is disabled and seems to hold Null in the Value property. If I click on the dropdown button, it re-checks the box.  Checked, the Value property holds the date.

Since I'm not able to type a ".", I suspect that you have another setting that is not part of the default.  Why not try adding a new one, rename the old, rename the new with the other one's original name, and see if you get the same results.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Here's the code you want :

 Private Sub Command1_Click()
   
    'NOTE: DTPicker cannot be null without a checkbox. (you get this error: Can't set Value to NULL when CheckBox property = FALSE.)

    If IsNull(DTPicker1.Value) = Null Then
        MsgBox "Date Time Picker is NOT checked and Has a NULL value"
    Else
        MsgBox "Date Time Picker has Value"
    End If

   
End Sub

Author

Commented:
Thanks guys, I think this is what I want.

Commented:
Actually, this is the one that seems to be correct (since IsNull returns a boolean:

  If IsNull(DTPicker1.Value) Then
    MsgBox "unchecked"
  Else
    MsgBox DTPicker1.Value
  End If

or
  If IsNull(DTPicker1.Value) =true Then
    MsgBox "unchecked"
  Else
    MsgBox DTPicker1.Value
  End If
good catch rspahitz!  

Commented:
Likewise with the IsNull...I've done so much DB stuff lately where everything is "If...Is Nothing" that I instintively just put "If...Is Null" which is obviously the wrong syntax.
Amen.  The wonderful thing about standards is that there are so many to choose from! And Microsoft has chosen them all!

Commented:
If the date field is null, then the checkbox is cleared.  If the field contains a date, then the checkbox is set.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
- split the points between twalgrave and rspahitz
Please leave any comments here within the
next seven days.
Per recommendation, force-accepted.

Netminder
EE Admin

rspahitz: points for you at http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_20434361.html

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial