PDA

View Full Version : [SOLVED] Help with datepicker control



rama4672
06-03-2004, 01:14 PM
I have a form with a date picker on it, When you click on the date it gives you a calender type date picker but it stays on the date that it was first set up,my question is how do i get the date to default to todays date.
I have looked at the properties of the form but there is no where that allows you to have the default day as today.

Thanks

Ian

Anne Troy
06-03-2004, 01:21 PM
You have a control?
Did you look at the properties of the control to see the target cell?

rama4672
06-03-2004, 01:44 PM
thanks for the reply anne
what control?
the target cell is ok
when it runs after you put the date in it is ok, I supose it is not a big problem I just thought it would look better if the first date it gave you as an option was todays, as i did it in april so when you run the form it defaults to the date in april.


Ian

Anne Troy
06-03-2004, 01:49 PM
Ian: Date picker = Control

What is that? A calendar?

Anne Troy
06-03-2004, 01:55 PM
Is this a template or a workbook?

SJ McAbney
06-03-2004, 02:00 PM
In the form initialize event:


Me.ctlPicker = Date()

Where ctlpicker is the name of your Date/Time Picker control

mark007
06-03-2004, 02:01 PM
Use:

DTPicker1.Value = Date

:)

rama4672
06-03-2004, 02:12 PM
Thanks for everybodys help in this Is now sorted, I used the suggestion from mark also abulafia suggestion worked as well



Private Sub DTPicker1_Enter()
'changes picker to current date
DTPicker1 = Date

End Sub


Regards

Ian

mark007
06-03-2004, 03:43 PM
Hi Rama,

Check out the vba tags for your code. The green and white icon ;)

On a technical note:

DTPicker1 = Date
implies:

DTPicker1.value = Date
as value is the default property of the datepicker object. Although not wrong it is good practice to explicitly use the property as in some scenarios it could result in errors.

:)

stapuff
06-08-2004, 11:15 AM
Rama4672,

Another option is the following. This is put in the calander userform.


Private Sub UserForm_Initialize()
Calendar1.Year = Year(Date)
Calendar1.Month = Month(Date)
Calendar1.Day = Day(Date)
End Sub


Kurt