Question On Date Picker Control
Why doesn't this work:
VB Code:
Private Sub DTPicker1_Click()
Text1.Text = DTPicker1.Value
End Sub
When I click on a date, nothing happens. I put a break at the beginning of this routine, and when I clicked nothing happened. This tells me the event, itself, is not firing and I don't know why.
Re: Question On Data Picker Control
Use the DTPicker1_Change() event.
VB Code:
Private Sub DTPicker1_Change()
Text1.Text = DTPicker1.Value
End Sub
Re: Question On Date Picker Control
1. That works, but why doesn't the click event work?
2. When I put the code in the Change event, and I scroll to a new month, dates get put in my textbox. I suppose that isn't the end of the world, but it looks kinda messy when I need to enter a date 4 months in the past, and while clicking back through the date picker, I get dates popping into the text box.
See number 1. Why isn't the click event fireing?
1 Attachment(s)
Re: Question On Date Picker Control
True, i had this problem a couple of days ago. The thing with this control is that you have to click it many times before finding a date in the calendar, which is why i thinkthe author has disabled full click events. The only time it will react to the click event if you click this bit here (marked in blue).
Re: Question On Date Picker Control
You could also use the CloseUp event that is fired when the drop-down is closed.
Re: Question On Date Picker Control
Quote:
Originally Posted by Joacim Andersson
You could also use the CloseUp event that is fired when the drop-down is closed.
Actually, I was doing that, but if I opened the date picker, but didn't want to actually select anything, it would pop today's date in the textbox when it closed, and that wasn't going to work.
So, the consensus is that the click event is functionally useless for acutally selecting a date??? What's up with that?
Re: Question On Date Picker Control
VB Code:
if DatePick.value = date then
exit sub
end if
Date is a VB keyword, and has the contains the current date.
Re: Question On Date Picker Control
Quote:
Originally Posted by I_Love_My_Vans
VB Code:
if DatePick.value = date then
exit sub
end if
Date is a VB keyword, and has the contains the current date.
Perhaps one out of 50 or 60 times will my user want the current date. Overwhelmingly, the date will either be from some month in the past, or some month in the future.
It looks like I will have to live with using the Change event.
Another question: My datepicker has a red circle (or oval) around the current date, which is fine, but it also has a gray circle (or oval) around the date I added it to my form. How do I get rid of that?
Re: Question On Date Picker Control
Quote:
but it also has a gray circle (or oval) around the date I added it to my form. How do I get rid of that?
The gray circle signifies the current Value of the date picker. There is no way to get rid of it by setting a property. There may be a way using the API or Subclassing the control.
Re: Question On Date Picker Control
Quote:
Originally Posted by brucevde
The gray circle signifies the current Value of the date picker. There is no way to get rid of it by setting a property. There may be a way using the API or Subclassing the control.
Which means you should be able to get rid of it by doing
VB Code:
Private Sub Form_Load()
DTPicker1.Value = Format(Now, "mm/dd/yyyy")
End Sub
Re: Question On Date Picker Control
Quote:
Originally Posted by Joacim Andersson
You could also use the CloseUp event that is fired when the drop-down is closed.
That also doesn't help if the user simply punches in the date (which is also why the changed event is better than the click even to detect changes.)
Quote:
Originally Posted by Hack
Which means you should be able to get rid of it by doing
VB Code:
Private Sub Form_Load()
DTPicker1.Value = Format(Now, "mm/dd/yyyy")
End Sub
:confused: *stares incredulously (sp?) at that and goes HUH?!*
Tg
Re: Question On Date Picker Control
Quote:
Originally Posted by techgnome
:confused: *stares incredulously (sp?) at that and goes HUH?!*Tg
Close your mouth, you will attract files... :D
What is so hard to understand? If you set the default value to today, then you get the little red circle, but not the little gray circle.
Re: Question On Date Picker Control
What you get is the little gray circle inside the little red circle.
Re: Question On Date Picker Control
Quote:
Originally Posted by Joacim Andersson
What you get is the little gray circle inside the little red circle.
Yes, but unless you are really looking, you won't notice it, and truthfully speaking, how many customers actually "look" at a screen. As long as it works, and nothing stands out as odd, they could use that date picker from now until forever, and never notice that the gray circle has moved inside the red circle. :thumb:
Re: Question On Date Picker Control
Then why bother moving it in the first place?
Tg
Re: Question On Date Picker Control
Quote:
Originally Posted by Hack
Close your mouth, you will attract files... :D
That only works for tri-occular frogs... not gnomes.... :p
Tg
Re: Question On Date Picker Control
Quote:
Originally Posted by techgnome
Then why bother moving it in the first place?
Tg
'Cause I have had customers notice there are are two ovals on the calendar, but I've never had one come back and say there are two ovals on the same date.