Re: Calendar Control 10.0 Missing Events
- From: "deko" <deko@xxxxxxxxxx>
- Date: Sun, 12 Feb 2006 14:07:10 -0800
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
.
- References:
- Calendar Control 10.0 Missing Events
- From: jodyblau
- Calendar Control 10.0 Missing Events
- Prev by Date: Re: Calendar Control 10.0 Missing Events
- Next by Date: Re: MS Access and Sharepoint: saving the username and password in a linked table
- Previous by thread: Re: Calendar Control 10.0 Missing Events
- Index(es):
Relevant Pages
|