Setting selected date in ActiveX Calendar 10.0

  • Thread starter Thread starter Junkguy
  • Start date Start date
J

Junkguy

Hi,

Can anyone tell me how to set the selected date of the ActiveX Calendar
Control 10.0 from Visual Basic? I have a Calendar Control in a form and I want
to set it to today's date when the form opens. Also I want to be able to set
it arbitrarily from my VB code.

Also, I have looked for the APIs for the Calendar control but can't seem to
find a good reference for it. Where exactly can I find this information?

Thanks!
 
Why bother trying to set the date of the ActiveX control? Why not just
set the default date in the underlying field to =Date()?

grep
 
If there is no underlying field - for instance, you are just picking a date
range for a report - then use something like this in the form's load event:
Private Sub Form_Load()
Me.Beginning_Date.Value = DateSerial(Year(Date), Month(Date) - 1, 1)
Me.Ending_Date.Value = DateAdd("m", 1, Me.Beginning_Date) - 1
End Sub

where beginning_date is the name of the first active x control and
Ending_date is the second. In this case, the dates default to the previous
months, but you can put any default you want here.

HTH
Damon
 
grep <[email protected]> said:
Why bother trying to set the date of the ActiveX control? Why not just
set the default date in the underlying field to =Date()?

I am not using an underlying field for the control. In my case I am using the
Calendar to change filter options for subforms. I.e. I show records in a
subform based on the date chosen in the control (which is on the main form). A
little outside the norm I know. Your question leads me to reconsider how to
set up the control. Perhaps if I simply gave it a dummy field I could
manipulate it that way?

Thanks,
 
Damon Heron said:
If there is no underlying field - for instance, you are just picking a date
range for a report - then use something like this in the form's load event:
Private Sub Form_Load()
Me.Beginning_Date.Value = DateSerial(Year(Date), Month(Date) - 1, 1)
Me.Ending_Date.Value = DateAdd("m", 1, Me.Beginning_Date) - 1
End Sub

where beginning_date is the name of the first active x control and
Ending_date is the second. In this case, the dates default to the previous
months, but you can put any default you want here.

Thanks, I'll give that a shot.

Much appreciated!
 
Back
Top