-
The calendar should open up with the date or ctlD value. If I don't have a date in txtReview I get a runtime error 13. If I Dim out .InitialDate = ctlD.Value then it work but it does not set the value if there is a date in txtReview.
I included all the code in case I missed something else.
Thanks for the help. I have learned lots from this forum.
ActiveX and form code
Code:
Public Property Set DateControl(ByVal ctlDate As Control)
Set mctlDate = ctlDate
End Property
Public Property Let InitialDate(datd As Date)
Me!ctlCalendar.Value = datd
End Property
Private Sub SetAndClose()
If mctlDate Is Nothing Then
MsgBox "The Date Control property has not been set", , "Calendar Form Error"
Else
mctlDate = ctlCalendar.Value
End If
End Sub
Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Click
DoCmd.Close
Exit_cmdExit_Click:
Exit Sub
Err_cmdExit_Click:
MsgBox Err.Description
Resume Exit_cmdExit_Click
End Sub
Private Sub ctlCalendar_Click()
SetAndClose
End Sub
Private Sub ctlCalendar_KeyUp(KeyCode As Integer, ByVal Shift As Integer)
Select Case KeyCode
Case vbKeyReturn ' carriage return
SetAndClose
Case vbKeyEscape ' escape
DoCmd.Close
End Select
End Sub
command button on click code
Private Sub cmdCalendar1_Click()
Dim frmCal As Form
Dim ctlD As Control
Set ctlD = Me!txtReview
DoCmd.OpenForm "frmCalendar", , , , , acHidden
Set frmCal = Forms("frmCalendar")
With frmCal
Set .DateControl = ctlD
'.InitialDate = ctlD.Value 'only works if I rem this out
.Visible = True
End With
End Sub
-
My subject should say activeX control won't work if ctlD.Value has a NO value.
Please help.
Thanks
Utracman