ActiveX Control Calander

D

Dave

Hi,

I have inserted a calander, in a form, using the ActiveX
Control where users will select dates. I have two
questions:

First, is there a way to adjust the pull-down menu at the
top right corner which lets you select a year. The years
currently range from 1900 to 2100. Is there a way to
limit the range to... say, starting at this year (2003)
and go to... say, ten years from now? I do not see
anything in the ActiveX Control properties which allows
you to do this.

Second, is there a way to default the calander to display
the current day/month/year when the form is opened?

Thanks, Dave
 
A

Arvin Meyer

I don't think there's any way to adjust the combo box dates.

Code like this ought to help:

Private Sub calCtrl_Click()
' Set the textbox = to the date clicked
Me.txtTestDate = Me.calCtrl.Value
Me.txtTestDate.SetFocus
Me.calCtrl.Visible = False
End Sub

Private Sub cmdCal_Click()
' Make the calendar visible
Me.calCtrl.Visible = True

' If the textbox is null use today's date
If Not IsNull(Me.txtTestDate) Then
Me.calCtrl.Value = Me.txtTestDate
Else
Me.calCtrl.Value = Date
End If

End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
V

Van T. Dinh

Don't know about the first question but the answer to the second question
will set the year to current year and the user doesn't have to traverse from
1900.

For the second question, there is the Today Method of the Calendar Control
you can use to set the Value of the Calendar Control to today. However, you
need to use this method in the Form_Current Event rather than the earlier
events.
 
J

Jeff Conrad

Van,

I've been using the Today Method of the calendar control
in Access 97 and 2000 for years in the form's Load event.
I've never had a problem using that event before. It
always defaults to the current day.

Jeff Conrad
Bend, Oregon
 
V

Van T. Dinh

Your are correct.

I actually tested before I posted but I used existing code and I uncommented
the wrong line of code. The Today Method works fine even in the Open Event
but if you use

Me.CalendarControl.Value = Date()

(which was the wrong code I tested), it doesn't work until the Current Event
(tested in A2K).
 
M

Mike Matheny

I use
Private Sub Form_Load()
Calendar0.Value = Now
End Sub

and it always defaults to the current date.
 

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