I have many forms that use the same ActiveX Calendar Control. I would like to make just one form to contain this Calendar control, and have each form that needs it call it as a function, passing it the name of the calling form and the fieldname that will receive the dateselected by the user. How do I code this? Do I use a form object variable?
From: Shamil Salakhetdinov <shamil@kommik.spb.ru>
Subject: Re: Generic Form for Calendar Control
Date: 16 March 1999 23:19
Ed,
Enclosed you'll find one of the possible solutions of the subject.
HTH,
Shamil
P.S. The code:
'*+
' Calendar Form Wrapping Class
' Written by Shamil Salakhetdinov, 15-mar-1999
' E-mail: shamil@marta.darts.spb.ru
'
' Notes:
'
' - this class is used together with frmCalendar form having (at least)
' Calendar ActiveX control named ctlCalendar
' - frmCalendar.Hasmodule property should be set to True
' - desirable to have also frmCalendar.Popup = True and
' frmCalendar.Modal = True
'
' Usage:
'
' Private Sub cmdGetDate_Click()
' Dim obj As New CCalendar
' ' txtDate is a control which gets date value selected from
' ' frmCalendar
' obj.GetDate Me, Me![txtDate]
' End Sub
'*-
Private Const mcstrClassName As String = "CCalendar"
Private mobjSelfRef As CCalendar
Private mfrmCalledBy As Access.Form
Private mctl2GetDate As Access.Control
Private WithEvents mfrm As Access.Form
Public Sub GetDate(ByRef rfrmCalledBy As Access.Form, _
ByRef rctl2GetDate As Access.Control)
Set mfrmCalledBy = rfrmCalledBy
Set mctl2GetDate = rctl2GetDate
Set mfrm = New Form_frmCalendar
mfrm.OnUnload = "[Event procedure]"
mfrm.Visible = True
Set mobjSelfRef = Me
End Sub
Private Sub mfrm_Unload(Cancel As Integer)
mctl2GetDate.Value = mfrm.ctlCalendar.Value
mfrmCalledBy.SetFocus
mctl2GetDate.SetFocus
Set mctl2GetDate = Nothing
Set mfrmCalledBy = Nothing
Set mobjSelfRef = Nothing
End Sub
| HOME TOPICS |
Copyright © 1999 by Shamil Salakhetdinov.
|
| Last updated: October 10, 2006
Published also here at 4TOPS: Generic Form for Calendar Control |
|