I inherited this and need to understand it. Can someone point me to a reference that explains what is being done here and why this method would be preferable over the normal object designer?
I understand this creates a calender object. I don't understand being able to view the form design in the vba window but not in the navigation pane. Also, when I right click to switch between View Code and View Object on a normally created form, I am sent back to the database window / navigation pane.
Code below, screenshot attached.
I understand this creates a calender object. I don't understand being able to view the form design in the vba window but not in the navigation pane. Also, when I right click to switch between View Code and View Object on a normally created form, I am sent back to the database window / navigation pane.
Code below, screenshot attached.
Code:
Option Compare Database
Option Explicit
Private WithEvents Calendar1 As clsCalendar
Public Target As Date
Private Sub UserForm_Initialize()
If Calendar1 Is Nothing Then
Set Calendar1 = New clsCalendar
With Calendar1
.Add_Calendar_into_Frame Me.Frame1
.UseDefaultBackColors = False
.DayLength = 3
.MonthLength = mlENShort
.Height = 140
.Width = 180
.GridFont.Size = 7
.DayFont.Size = 7
.Refresh
End With
Me.Height = 173 'Win7 Aero
Me.Width = 197
End If
End Sub
Private Sub UserForm_Activate()
If IsDate(Target) Then
Calendar1.Value = Target
End If
End Sub
Private Sub Calendar1_Click()
Call CloseDatePicker(True)
End Sub
Private Sub Calendar1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyEscape Then
Call CloseDatePicker(False)
End If
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = 1
CloseDatePicker (False)
End If
End Sub
Sub CloseDatePicker(Save As Boolean)
If Save And IsDate(Calendar1.Value) Then
Target = Calendar1.Value
End If
Me.Hide
End Sub