I am trying to use the Calender Controls to enter a date range for a report. How can I set a default date in these type of controls?
Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
I am trying to use the Calender Controls to enter a date range for a report. How can I set a default date in these type of controls?
Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

This month, every Windows Secrets subscriber can download a one-chapter excerpt of Windows 7: The Missing Manual.Windows 7: The Missing Manual provides valuable information to help you overcome these difficulties in learning a new operating system. Subscribe today to download your free excerpt.
If you mean the Microsoft Calendar control, it's an ActiveX control, not an Access control; it doesn't have a DefaultValue property.
You can set the value of the control in the OnLoad or OnOpen event of the form that contains the control; for instance
calDateSelect = Date
if you want to set the value of the calDateSelect control to the current date.
Thanks for your response Hans, and yes I understand it's an ActiveX control, I just wasn't explicit enough.
I have the following in the OnOpen event of the form, but it still does not work.
Dim dteDate As Date
dteDate = DLookup("[DecidedDate]", "[qry Latest Date Decided]")
TextDateFrom = dteDate
where TextDateFrom is the ActiveX control.
Any ideas why?
Pat <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
Hi Pat,
Your code looks OK. Try putting a breakpoint in the OnOpen event and single-stepping through the code. Does dteDate get assigned the date you expect?
It sure does. However when the line is executed that sets up the date from dteDate and I look at the value in the ActiveX control in the immediate window there is a blank line.
I have done this before in Access 97 but I put the code in the OnEnter event of the ActiveX control and that seemed to work.
This is stumping me, this one.
I appreciate your help on this one.
Pat
Sorry, I'm out of ideas here. The calendar controls I have on my system (Microsoft Calendar Control and Microsoft Date and Time Picker Control) both can be set in code OK. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
I have been experimenting and have found if I put the code in the OnEnter event of the control and I click at the top of the control it works.
What I want to do is somehow simulate that in code.
Any more ideas in light of above? Is there a certain version I should have, I currently have version 7.
Pat <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
What happens if you set the value of TextDateFrom in the OnLoad event instead of in the OnOpen event of the form? The OnLoad occurs later in the chain of events.
Perhaps this will help Patt.
I changed my Calender controls to what I've included in the attachment.
It seems to work pretty well for me.
The only difference I see from your code is only slight but may solve your problem.
Private Sub calCalendar_Click()
Me.txtTemp = Me.calCalendar.Value
End Sub
Private Sub Form_Load()
If IsNull(Me.txtTemp) Then
Me.calCalendar.Value = Date
Else
Me.calCalendar.Value = Me.txtTemp
End If
End Sub
Bingo Hans !!
The OnLoad event seems to be the right event, as Dave also pointed out.
Thank you for your time and expertise.
Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>