By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,631 Members | 1,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,631 IT Pros & Developers. It's quick & easy.

Calendar Control 10.0 Missing Events

P: n/a
I am trying use a Calendar Control 10.0 in one of my forms. (I am
using access 2002)

What I want to do is have the user click a button which makes the
calendar visible. Then when the user clicks on a date, it sends it to
a text box and then the calendar should disappear.

All of the examples I have been able to track down seem to use events
that aren't available to me. Most notably, any click events.

When I bring up the proprites for the calendar and select the events
tab, I have the followng list of Events:
On Updated
On Enter
On Exit
On Got Focus
On Lost Focus

There are no other events listed. Can someone help me figure out how
to get this control to respond to the user clicking one of the calendar
dates?

Thank you,

Jody Blau

Feb 12 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
The Onclick event is available even though it isn't shown in the
properties sheet. Use something like:

Private Sub MyCal_click()
Me!MyTextBox = Me!MyCal.Value

HTH

Feb 12 '06 #2

P: n/a
> What I want to do is have the user click a button which makes the
calendar visible. Then when the user clicks on a date, it sends it to
a text box and then the calendar should disappear.


I encountered this exact same issue. I put the calendar control in a popup
form and passed a comma-delimited string in OpenArgs:

[frmPopupCalendar]
Option Compare Database
Option Explicit
Private m_astrOpenArgs() As String

Private Sub Form_Open(Cancel As Integer)
m_astrOpenArgs = Split(Me.OpenArgs, ",")
End Sub

I have a number of forms/subforms in my app that use the calendar control.
Each has a button that opens the popup form with an OpenArgs parameter like
this:

"frmFormName,frmSubFormName,frmNestedSubFormName,t xtControlName,strPopupFormCaption"

If a parameter is not needed, I just leave it blank:

"frmMain,txtMyDate,,,,Please Select a Transaction Date"

In the AfterUpdate event of the Calendar control, I have this:

Private Sub MyCalendarControl_AfterUpdate()
Call SetDateOnClose(m_astrOpenArgs(0), m_astrOpenArgs(1), _
m_astrOpenArgs(2), m_astrOpenArgs(3))
DoCmd.Close acForm, "frmPopupCalendar"
End Sub

Here is SetDateOnClose:

Private Sub SetDateOnClose(strFrm As String, strCtl As String, _
strSubFrm As String, strSubFrmCtl As String)
If Len(strSubFrmCtl) = 0 Then
If Len(strSubFrm) = 0 Then
Forms(strFrm).Controls(strCtl) = _
CDate(Me!MyCalendarControl.Value & " 12:00:01 AM")
Else
Forms(strFrm).Controls(strCtl).Form.Controls(strSu bFrm) = _
CDate(Me!MyCalendarControl.Value & " 12:00:01 AM")
End If
Else
Forms(strFrm).Controls(strCtl).Form.Controls _
(strSubFrm).Form.Controls(strSubFrmCtl) = _
CDate(Me!MyCalendarControl.Value & " 12:00:01 AM")
End If
End Sub

The only reason I append "12:00:01 AM" is because I have logic elsewhere
that needs a date with a time value.

I often want the calendar to display a particular date on open - usually the
date that's in the control on the form from which the calendar was opened:

Private Sub Form_Load()
Me!ApptCal.Value = GetDateOnLoad(m_astrOpenArgs(0), m_astrOpenArgs(1), _
m_astrOpenArgs(2), m_astrOpenArgs(3))
Me.Caption = m_astrOpenArgs(4)
End Sub

Private Function GetDateOnLoad(strFrm As String, strCtl As String, _
strSubFrm As String, strSubFrmCtl As String) As Date
On Error GoTo HandleErr
If Len(strSubFrmCtl) = 0 Then
If Len(strSubFrm) = 0 Then
Me!ApptCal.Value = Nz(Forms(strFrm).Controls(strCtl), Date)
Else
Me!ApptCal.Value = Nz(Forms(strFrm).Controls(strCtl).Form. _
Controls(strSubFrm), Date)
End If
Else
Me!ApptCal.Value = Nz(Forms(strFrm).Controls(strCtl).Form.Controls _
(strSubFrm).Form.Controls(strSubFrmCtl), Date)
End If
End Function

Feb 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.