Calendar control default date

T

Tom Ross

an additional question. How do I make a calendar control default to the
current date. this has bugged me for some time.

Thanks

Tom
 
P

PC Datasheet

Tom,

Put the following code in the OnOpen event of your calendar form:

Me!NameOfCalendarControl.Value = Date()
 
T

Tom Ross

Thanks

Tried that before and doesnt seem to work

I am using two unbound calendar controls on my form txtStartWeek and
txtFinishWeek
they are of type
calendar
MSCAL.calendar.7

I have this code in my form open event

Private Sub Form_Open(Cancel As Integer)
Me.txtStartWeek.Value = Date()
Me.txtFinishWeek.Value = Date()
End Sub

It doesn't work. I tried setting the value parameter in the control
properties to Date()--it wouldnt take it or Null--didnt make any difference.

What else can I try

Tom
 
J

Jeff Conrad

Move the code to the Load event instead of the Open event.
The Open event is too soon.

If it still does not work try this in the Load event:

Private Sub Form_Load()
Me.txtStartWeek.Today
Me.txtFinishWeek.Today
End Sub

(Assuming those are the actual names of the calendar controls.)
 
T

Tom Ross

Jeff

the Load Event is where it needed to be. My previous code worked there .
Have a nice weekend

Tom
 

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