Re: Calendar Control 10.0 Missing Events



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,txtControlName,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(strSubFrm) = _
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

.



Relevant Pages

  • Re: How to reference and populate controls on Content Page
    ... Calendar page does not use masterpage. ... Only the page that calls popup does. ... I have very little code in the page that calls the calendar popup. ... string strDate = calDate.SelectedDate.ToShortDateString; ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Discrepancy in current hour
    ... I thought the advice I was getting was that ALL of the code was ... crap and should all be redone to use DateFormat and SimpleDateFormat. ... And again, when you mentioned using Calendar again, I thought you were ... Those related to providing String representations. ...
    (comp.lang.java.programmer)
  • Re: Possible bug in Calendar
    ... Now stop the dishonest quoting and other extremely childish tricks and start discussing Java, ... My idea was of having Calendar implement a basic Date factory functionality and have non-standard calendars provide Date- or Calendar- wrapping and translation functionality, ... In other words, Date, Calendar, and LocalizedCalendar, analogously to the existing pattern of String, StringBuilder, and Collator, MessageBundle, and the other peripheral classes for localized String handling. ...
    (comp.lang.java.programmer)
  • RE: Add Time to popup calendar
    ... Calendar is Allen Browne's popup form: ... 'Public gtxtCalTarget As TextBox 'Text box to return the date from the ... Optional strTitle As String) ... Private Function SetSelected ...
    (microsoft.public.access.formscoding)
  • Re: Calendar coding
    ... > to call ActiveX Calendar which is on a form. ... > sub form.... ... > Private Sub ActivateCalendarForm(ByRef fForm As Form, ... > ByRef sCtrl As String) ...
    (microsoft.public.access.formscoding)