Results 1 to 18 of 18

Thread: DateTimePicker??

  1. #1

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134

    Question DateTimePicker??

    Using a date time picker, I’m getting a can not contain null value error when clicking the Save button.
    How can I fix that.
    Thanks!

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Can you show some code ?

  3. #3

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    There is no code I did not think that it needed code! cause the box already has text in it. "So I thought"
    If I was to try it rite now without touching the DataTimePicker it would Error out, but if I was to just pull the picker down and click on 19 it would work fine ??? It just errors if the Date is not clicked.
    Thanks!

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I don't know what's this problem . I tried to generate any error but it's all working . Are you using any cutome formats ?

  5. #5

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    MM/DD/YY
    That’s about it.
    I have two Forms and it does the same thing on both
    If it is seeing it as Null Value if not clicked, is there a way to code a date into it so that when using current date it don't have to be clicked?

  6. #6
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Where'd you get this Date/Time Picker?

  7. #7

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    OK! I apologize if I did not make myself clear enough.
    It is the DateTimePicker out of the Toolbox, it is a Data member in my DataSet
    Something screwy is been happening. At first I was using just a text box witch kept on putting 12:00am behind my date, that is why I decided to go with the DateTimePicker.
    All is well, unless I forget to Make a selection then I get the Null Value Error.
    I was under the Impression that the DateTimePicker automatically displays today’s date and that it would be sufficient to make a Data entry.
    I don’t Care witch one I use but they have both given me problems.
    One adds 12:00am and the other don’t auto select the date.
    ???????
    Last edited by Rally2000; Dec 20th, 2003 at 12:48 AM.

  8. #8
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    Your have to give it an initial value,weuse them and in the load event of the form always pust something like:

    DateTimePicker1.Value = Now

    unless of course you are binding it to exitisng data.

  9. #9
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    Your have to give it an initial value,weuse them and in the load event of the form always pust something like:

    DateTimePicker1.Value = Now

    unless of course you are binding it to exitisng data.

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I don't know really what's wrong and had no problems with this control before . You don't even need to set any value . Just paste it on your form and it should , get today's date , no need for any code .

  11. #11
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    In my forays into date/time picking... I noticed the need for this:

    1) If the user doesn't explicitly enter a value, the database should represent this as Null, not today's date.


    2) The control in the VS toolbox sets itself to today's date/time by default when it loads, effectively demolishing the logic rule set in #1.

    3) I always got around this by making a custom control that simply returns nothing in its DateTimeValue property if it was never set by the user, thereby effectively enforcing the first statement.

  12. #12

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    My DateTimePicker is bound to a database, and I have already found it to be a problem. It simply gets forgotten because the existing Date.
    Is there any way to fix this?

  13. #13

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    Anyone?

  14. #14
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    what's the control for exactly? Couldn't you just use a date funtion and paste the info on a label? Or is this a control for databases or something?

  15. #15
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    I think your problem is that you are trying to bind a null value date to the control. Cannot think of anything else as have never experienced the sorts of problems you describe with this control.

    Why not remove the binding and handle it through as Edit. Not a solution but I am at a loss as to understand why you are having the problems you do.

    If necessary you can always add a handler and use that instead of binding directly and in the handler code determines what to do if to if you try to parse a null value date.

    Perhaps post some code. I don't know and feel have nothing more I can contribute to this thread

  16. #16
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Data binding is hell . If you want to cut off this problem , create a property or variable that set/get the value from DTP control using DTP.Value method . It's much more safer to the user of your program .

  17. #17

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    I was thinking that, but also hoping for an easy fix.
    Thanks!

  18. #18
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Do it this way to have more control on your code . I know it's a bit longer but the output is readable and maintainable code .

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