Results 1 to 12 of 12

Thread: [RESOLVED] Date Time Picker and NULLs

  1. #1

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Resolved [RESOLVED] Date Time Picker and NULLs

    Hi guys, im facing a problem about dtpickers. It doesnt have an option to empty date. I have an access dbase and when the query is blank date it returns an error "cant accept null values"

    yeah i know that error but there's no option to empty date within DTpicker control. At first im using a textbox controls for date, but that would be difficult for the user to input date and i am oblige for a date validation procedure for that.

    Is there a work around with this? I find DT picker handy for entering date but it wont allow nulls from dbase.

    Im going in circles explaining... hope you dont mind...

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

    Re: Date Time Picker and NULLs

    I don't understand your question.

    If the date can't be null, then don't run the query unless you have a date.

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Date Time Picker and NULLs

    I believe there is an option to display a checkbox on the DateTimePicker. Use this option. Set it to display and unchecked first. When a user selects a date then the checkbox gets checked automaticaly. You can use the checkbox's checked status to post either NULL or a date value into the database.

    I have and example of that on the forums I'll have to search for it and post the link.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  4. #4

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Date Time Picker and NULLs

    OK i will rephrase my question.

    I created an app sort of a database manager with add/edit/delete/update etc.

    Now when i click add record, the date field is not be required really. You can enter a date or not. In which case, the DT picker has already values on it.

    I'll take you to where im gettin an error. I have a NULL value on the database date field although its datatype in access is not date but text. So when i try to query or movenext to the record with null date, it will return an error because DT picker WONT accept null values.

    How can i work around with this?

  5. #5
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Date Time Picker and NULLs

    Use the checkbox and just don't set the date. The values in the control will be greyed out unless actually selected by the user after that and the checkbox will becom checked. If the record has a NULL date field then you set the controls checkbox to False and don't attempt to post a date there.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  6. #6

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Date Time Picker and NULLs

    OK thanks for the prompt reply. I'll test that out if it will accpet null values from dbase.

  7. #7

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Date Time Picker and NULLs

    All right, Gary you are my saviour!

    However, can i make the DTpicker empty because eventhough it's disabled i can still see the date. Thanks anyway for the first part.

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

    Re: Date Time Picker and NULLs

    Don't use the value from the datepicker. I use the controls all the time and pop the selected date into a textbox.

    It is what is in the textbox that I use in queries.

    For your purposes, when a date not required just set txtDate.Text = vbNullString

  9. #9

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Date Time Picker and NULLs

    So its sort of additional controls?

    Its like a dummy controls wherein from db to textdate.txt and pass the value to the datepicker? is that it?

  10. #10
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Date Time Picker and NULLs

    basicly yest that is is.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

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

    Re: Date Time Picker and NULLs

    And this is how I use the datepicker. Today's date in a textbox. The little down arrow to its right is the datepicker control. Throughout my entire project, as well as several others before this, that is the only part of the entire control that ever appears on the screen. And, it sits right next to a textbox.
    Attached Images Attached Images  

  12. #12

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Date Time Picker and NULLs

    That nailed it.

    Sweet baby! Yeah! Marry me.

    Bravo! I wasn't creative enough.

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