-
May 18th, 2005, 02:41 AM
#1
Blank DateTimePicker
I m using datetimepicker in my form and i want when user click on new button then it set the datetimepicker value to blank.
Is this possible to set the values of dtpicker to null or is there any other control available which can be used instead of DateTimePicker?
Thanks In advance
-
May 18th, 2005, 02:58 AM
#2
Re: Blank DateTimePicker
Code:
DTPicker1.CheckBox = True
DTPicker1.Value = Null
remember the date will be displayed in the DTPicker, however when you try to access the Value property, it will return null..
you cannot have a Blank DTPicker...
-
May 18th, 2005, 05:03 AM
#3
Re: Blank DateTimePicker
Originally Posted by vb_the_best
[code]DTPicker1.CheckBox = True
you cannot have a Blank DTPicker...
yes, you can..
set the format to 3: dtpCustomFormat
then in the custom page, set the format to a space
it makes it appear blank, but this is NOT a good idea, because it then looks like a combobox
note: to get it to show anything the user picks, you must change the format when they pick something, otherwise the date value will always be formatted as a space (dumm..)
Private Sub DTPicker1_Change()
DTPicker1.Format = dtpCustom
DTPicker1.CustomFormat = "yyyy MM dd"
End Sub
-
May 18th, 2005, 02:31 PM
#4
Re: Blank DateTimePicker
Seems to me there is a property which adds a checkbox to the left of the date, and the user can check the box if they want to use the date shown. I haven't really looked at that much though.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
November 27th, 2005, 05:09 AM
#5
Re: Blank DateTimePicker
Originally Posted by WizBang
Seems to me there is a property which adds a checkbox to the left of the date, and the user can check the box if they want to use the date shown. I haven't really looked at that much though.
This will work very well if you can use the change in state of the check box. If the checkbox is selected, the fontcolour is black, if the checkbox is not selected, the fontcolour = the backcolour, BUT HOW TO DO THIS ???
-
November 27th, 2005, 08:29 AM
#6
Re: Blank DateTimePicker
Originally Posted by jvzmuller
This will work very well if you can use the change in state of the check box. If the checkbox is selected, the fontcolour is black, if the checkbox is not selected, the fontcolour = the backcolour, BUT HOW TO DO THIS ???
The problem is that the color is internally set to appear "grayed". I doubt it is easy to override that behavior, if not impossible.
Suppose you disable the control instead? You can use a seporate checkbox next to it to enable/disable it.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
November 28th, 2005, 03:46 AM
#7
Re: Blank DateTimePicker
Originally Posted by WizBang
The problem is that the color is internally set to appear "grayed". I doubt it is easy to override that behavior, if not impossible.
Suppose you disable the control instead? You can use a seporate checkbox next to it to enable/disable it.
Is it possible to fire the checkbox in the DateTimePicker remotely from another checkbox. I mean can you select one checkbox and it will select the checkbox in the DateTimePicker?
-
November 28th, 2005, 05:53 AM
#8
Re: Blank DateTimePicker
Originally Posted by jvzmuller
Is it possible to fire the checkbox in the DateTimePicker remotely from another checkbox. I mean can you select one checkbox and it will select the checkbox in the DateTimePicker?
That's probably possible, but how will it help achieve your objective? The user can already click the checkbox inside the DTPicker. Then there is still the issue of setting the color. Even if that can be done, when the user highlights the hidden date, it will show up anyway.
If you don't want to disable the control, then perhaps set the Visible property to False, so it will not be seen?
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
November 28th, 2005, 06:33 AM
#9
Re: Blank DateTimePicker
Originally Posted by WizBang
That's probably possible, but how will it help achieve your objective? The user can already click the checkbox inside the DTPicker. Then there is still the issue of setting the color. Even if that can be done, when the user highlights the hidden date, it will show up anyway.
If you don't want to disable the control, then perhaps set the Visible property to False, so it will not be seen?
The origin of the problem is because I am to stupid to know how to delete the date field. What I want to do is to have several text boxes on a form. some of the textboxes are linked to date fields in an Access table. I have amongs others EDIT and UPDATE buttons. If you click the EDIT button, all the textboxes are enabled and you can edit or delete text in textboxes. If you hit the UPDATE button, it must update the table. After strugling for a long time I entered code in the UPDATE button to detect which date field has been delete and to set that field to NULL with a SQL command. It continue to give me an error allthough if you close the form and re-open it, the date field has been deleted. After many attempts I try to work with the DateTimePicker, the only problem is that it cannot be blank. It handle the delete of that date field easily. So if I can "remotely trigger" the check box, I can make the Date Time Picker invisible. I will put a textbox and the datetimepicker link to the same field. I want to code the textbox lostfocus event to set the checkbox in the date time picker to unchecked if the textbox is empty. (Does all this make sense???)
-
November 28th, 2005, 03:12 PM
#10
Re: Blank DateTimePicker
I see. Thanks for explaining it.
I think I'd try to avoid using the DTPicker, though it might help with keeping date formats as needed.
If you try to set a textbox to NULL, it will give an error. I don't know if that was part of the problem, but if you have any NULL fields tied to textboxes, you can use a vbNullString to avoid the error.
Something like this:
Code:
Text1 = NULL_From_DB & vbNullString
It might also be that the date field doesn't accept a vbNullString as a value, which is what an empty textbox is.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
November 29th, 2005, 12:22 AM
#11
Re: Blank DateTimePicker
Originally Posted by WizBang
I see. Thanks for explaining it.
I think I'd try to avoid using the DTPicker, though it might help with keeping date formats as needed.
If you try to set a textbox to NULL, it will give an error. I don't know if that was part of the problem, but if you have any NULL fields tied to textboxes, you can use a vbNullString to avoid the error.
Something like this:
Code:
Text1 = NULL_From_DB & vbNullString
It might also be that the date field doesn't accept a vbNullString as a value, which is what an empty textbox is.
Thank you for your time. I have tried that it still give me that same error.
-
November 29th, 2005, 05:02 AM
#12
Re: Blank DateTimePicker
What was the error you got? When did it occur? Was it a database driver error, or was it generated by the code in your program? If the error is from the database driver, and you have the textbox bound to the db, that might be a problem for fields that can return NULL. I don't know what happenes in that case, since I've never tried binding a textbox to a date field.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|