[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... :D
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.
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.
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?
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.
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.
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.
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
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?
Re: Date Time Picker and NULLs
1 Attachment(s)
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.
Re: Date Time Picker and NULLs
That nailed it.
Sweet baby! Yeah! Marry me.
Bravo! I wasn't creative enough. :)