Date/Time Picker

M

MikeS

I have a Date/Time Picker on my form with which I wish to use the current
date as the default. However, when I try to this:

Me.DTPicker1.Value = Format(Date(), "mm/dd/yyyy")

I get and error saying that the "Property is read-only".

Can anyone explain this to me?

Thanks in advance,

Mike
 
K

Klatuu

At last count, there were about 17,325 different versions of date/time
pickers available.
Which one are you using?
 
L

Linq Adams via AccessMonster.com

Is that all, Dave? I'd have thought it was closer to the national debt! ;0)>

AT any rate, the problem is you're trying to tell the DatePicker ***how*** to
display the date, by using Format, and you can't do that! It's going to
display the date ***graphically*** as it's programmed to do, not as
"mm/dd/yyyy." If you need to format the display in your textbox differently,
you can do that elsewhere, after the datepicker's been used and the date's
been entered. You should be able to set the Default, though, with

Me.DTPicker1.Value = Date()
 
M

MikeS

The version is "Microsoft Date and Time Picker Control 6.0"

And it doesn't matter if I use the format option or not - I still get the
same error.

However, I just tried using this statement in the "On Load" event instead of
the "On Open" event and it works fine now.

Not sure what the difference is.
 
K

Klatuu

Correct. There is a subtle difference between the Open and Load events.
During the Open event, not all the form's properties and objects have been
established and you can be referring to something it doesn't know about yet.

Notice the Open event can be canceled. The Open event should really only be
used to determine whether or not to continue loading the form or to cancel
the opening of the form. For anything else you need to do to configure the
form for the session, use the Load event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top