Date and Time Picker

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Date and Time Picker Control and I want to set the Value to today's
date. It seems like it should be easy:

Me.DtPicker1.Value = Date

I have also tried:

Dim Today as String ' also tried Date
Today = Date ' also tried Now
Me.DTPicker1.Value = Today

In all cases I get the error message:

Run-time error '2448':
You can't assign a Value to this object.

I have also tried to set focus and many other ideas.

The control is unbound - and I ultimately want to use the value to set a
date variable in a module. This part works - I just want to set the
displayed value when I open the form to Today's date.

Argh!

Rob.
 
I didn't see a default value on the properties page, but when I went into my
code sample, I typed in "Me.DtPicker1." and Default popped up so I continued
as "Me.DtPicker1.Default = " and the next thing came popping up was either
"=True" or "=False".

So there is a .default option but its a boolean value and I don't know how
its used behind the scenes.
 
Which DatePicker are you using, the one that comes with Access?

Where are you placing the code "Me.DtPicker1.Value = Date"?
 
I don't have VB loaded to see what the settings are on that control. You may
get more help in the VB newsgroups.
 
PS.

If you also don't have VB loaded, but the control is available on your
computer, it may have been placed there by another program that uses or used
it. Without VB loaded, you won't have the license necessary to use the
control in a development environment and will have problems such as what
you're running into.
 
Here is the code I use on my forms onload event.

Private Sub Form_Load()
Dim m As Integer
Dim d As Integer
Dim y As Integer

m = Format((DateAdd("d", (2 - (Weekday(Date))), Date)), "m")
d = Format((DateAdd("d", (2 - (Weekday(Date))), Date)), "d")
y = Format((DateAdd("d", (2 - (Weekday(Date))), Date)), "yyyy")

Me.DT_Start_Date.Month = m
Me.DT_Start_Date.Day = d
Me.DT_Start_Date.Year = y

End Sub
 
Back
Top