Set Calendar Control Date other than Today

grnzbra

Registered User.
Local time
Today, 00:31
Joined
Dec 5, 2001
Messages
376
I have ActiveX Calendar Control 10 in Access 2003 on a form that is called from another form that feeds in a date in OpenArgs. The date will NOT be today's date. I need to have the calendar set to that date. All threads dealing with setting the date seem to set it to today's date. How can I set it for another date?
 
Could you show me the code? I would imagine something like.

Code:
'set date
DoCmd.OpenForm "frmYourForm", acNormal, , , , , #1/6/2006#

'now + 7 days
DoCmd.OpenForm "frmYourForm", acNormal, , , , , DateAdd("d", 7, Now)
 
As an alternative and maybe more flexible, declare a global date variable, eg pubStoreDate. Set this to the value of the feeding control before opening the new form.

In the form Open event, set your calandar control to pubStoreDate.
 
This is some code that doesn't work (the call to open the form works fine)

Private Sub Form_Open(Cancel As Integer)
Dim dt As String

dt = format(OpenArgs,"yyyy")
Me.StDtSel.Year= dt
dt = Format(OpenArgs, "m")
Me.StDtSel.Month = dt
dt = Format(OpenArgs, "d")
Me.StDtSel.Day = dt
End Sub


I've also tried setting the Value property of the control to the whole date and tried to set the control source to the date. Nothing seems to work.

OK. I found the trick:

dt = OpenArgs
Me.EnDtSel.SetFocus
Me.EnDtSel.Value = dt
 
Last edited:
No. I was pulled off that project and had to work on something else. But I've just gone with two text boxes for them to enter the dates. That works ok.
 

Users who are viewing this thread

Back
Top Bottom