Default Value for DTPicker

ions

Access User
Local time
Today, 04:23
Joined
May 23, 2004
Messages
816
How can I set the default Value for the DTPicker?

I tried to set the value for the date picker using Me.Date.Value = Date
during the on Open event of the form containing the DTPicker however I got the error message DTpicker is Read only. When I try to set the value of the DTPicker using the field options it only allows me to select a specific date.

THanks very much for your response.
 
You should *not* name your control "Date" as it is a reserved word. You also can not reference a control on your form in the open event of the form because it is too early in the process. Use the OnLoad event instead. I put:
Me.DTPicker5 = #1/1/2007#
in the OnLoad event and it worked just fine.
 
Hi Rural Guy

I changed the name of the DTPicker field to DateDtPicker. On the OnLoad event of the form which the DateDTPicker resides is put Me.DateDTPicker = #1/1/2007# and I still received the same error message.

DTPicker is Read Only.

I also tried Me.DTPicker.value = #1/1/2007#

hmmmm not sure why it's not working for me.
 
Is your DatePicker control bound to a field in the RecordSource of the form and is that field changeable? I used an unbound DatePicker control for my test.
 
No Rural Guy it is not bound. The recordsource property is left empty.

I am running Access 2003.

Not sure why it's not working for me.

I can set the Default value in the control's menu's but only to a particular date and not now() or Date ().

Hmmmm any suggestions?

Thanks
 
I used a bound date/time picker for my test and it worked great setting using this for the value:

Private Sub Form_Load()
Me.dteDateTime = Date
End Sub

or

Private Sub Form_Load()
Me.dteDateTime = Now
End Sub

It also worked for me with an unbound control.
 
I'm always curious when I see this question posted; what version of Date/Time Picker are we discussing here? I run Access 2000 with M$ DateTime Picker
ver. 6.0, and it automatically defaults to the current date, without any intervention by anyone. It can be set to default to other dates as well, as Bob and RG have indicated. I've even set the default in it's AfterUpdate event so that it defaults to the last date picked, which is helpful to a data entry person entering a week's worth of records at a time.
 
Not working for me

Attached is the error message and the code.

I am not sure why it's not working for me.
 

Attachments

  • Error.GIF
    Error.GIF
    51 KB · Views: 298
  • ErrorCode.GIF
    ErrorCode.GIF
    51.6 KB · Views: 315
Can you make changes to the record manually? It's possible you can't set it because the recordset is non-updatable and that is why you can't set it.
 
Hi Boblarson

Yes I can change the control manually by selecting a different date.
Note sure what is happening.
 
Thanks to all who responded. I Just realized my mistake. As RuralGuy mentioned I should not call the DTPicker control Date. That was the problem.

Thank you for your assistance.
 

Users who are viewing this thread

Back
Top Bottom