G
Guest
I have written a simple form containing a calendar control, that can be used
when entering date values. It is called by double-clicking on the control. It
works really well as it uses the screen.active control to pass the reference
to the control so is not hard coded in any way and works whether the control
is on a form, subform or nested subform.
The problem I have is that as I am changing the value of the control
programmatically if it has an AfterUpdate event it will not fire. I can
detect if there is an event using:
If objControl.AfterUpdate = "[Event Procedure]"
What I can't work out is how to fire this event - I am trying to avoid
hard-coding form/object names so that the calendar form can be used
throughout my application (and indeed other databases).
'*** START OF CODE ***
Option Compare Database
Option Explicit
Dim objControl As Object
Private Sub cmdClose_Click()
DoCmd.Close
End Sub
Private Sub cmdCloseandCopy_Click()
axCalendar_DblClick
End Sub
Private Sub axCalendar_DblClick()
objControl = Me.axCalendar.Value
Set objControl = Nothing
DoCmd.Close
End Sub
Private Sub Form_Load()
'*** Set Calendar to Control's Current Value or Current Date if Blank ***
Me.axCalendar.Value = Screen.ActiveControl.Value
If IsNull(Screen.ActiveControl.Value) Then Me.axCalendar = Date
Set objControl = Screen.ActiveControl
End Sub
'*** END OF CODE ***
when entering date values. It is called by double-clicking on the control. It
works really well as it uses the screen.active control to pass the reference
to the control so is not hard coded in any way and works whether the control
is on a form, subform or nested subform.
The problem I have is that as I am changing the value of the control
programmatically if it has an AfterUpdate event it will not fire. I can
detect if there is an event using:
If objControl.AfterUpdate = "[Event Procedure]"
What I can't work out is how to fire this event - I am trying to avoid
hard-coding form/object names so that the calendar form can be used
throughout my application (and indeed other databases).
'*** START OF CODE ***
Option Compare Database
Option Explicit
Dim objControl As Object
Private Sub cmdClose_Click()
DoCmd.Close
End Sub
Private Sub cmdCloseandCopy_Click()
axCalendar_DblClick
End Sub
Private Sub axCalendar_DblClick()
objControl = Me.axCalendar.Value
Set objControl = Nothing
DoCmd.Close
End Sub
Private Sub Form_Load()
'*** Set Calendar to Control's Current Value or Current Date if Blank ***
Me.axCalendar.Value = Screen.ActiveControl.Value
If IsNull(Screen.ActiveControl.Value) Then Me.axCalendar = Date
Set objControl = Screen.ActiveControl
End Sub
'*** END OF CODE ***