G
Guest
All
My overall goal today is to put together a few class we can drop in our new Access (2000) apps. The first of these jewels, the calendar form
I've dropped a calendar control and command button (cmbOk) onto an Access form (frmCal). The form has a custom event BeforeHide(ValueOfCalendarControl As Date), which has a date parameter - the value of the calendar control.
Public Event BeforeHide(ByVal dteDteSel As Date
The event is `raised` when the Ok (cmbOk) button is clicked, which causes the form to become invisible
Private Sub cmbOk_Click(
RaiseEvent BeforeHide(mdteDteSel
Let Me.Visible = Fals
End Su
This form also has 2-methods CloseSelf() and OpenSelf() - code below. CloseSelf() closes the form, and OpenSelf() opens the form
Public Function CloseSelf(
Call DoCmd.Close(acForm, Me.Name
End Functio
Public Function OpenSelf(
Call DoCmd.OpenForm(Me.Name, acNormal
End Functio
For testing purposes, I've made another form (frmTest). I've got a text box on this (test) form, which when double-clicked spawns my nifty calendar modal. I select a date and click the Ok button and the form disappears as expected; however, the test form never receives the date because the BeforeHide() event is never trapped. Here is the code for my test form
Private WithEvents frm As Form_frmCa
Private Sub Form_Load(
Set frm = New Form_frmCa
End Su
Private Sub Form_Unload(Cancel As Integer
Call frm.CloseSel
Set frm = Nothin
End Su
Private Sub frm_BeforeHide(ByVal dteDteSel As Date
Debug.Print "The BeforeHide() event executed!
Let Me.tbDate.Value = CStr(dteDteSel
End Su
Private Sub tbDate_DblClick(Cancel As Integer
Call frm.OpenSel
End Su
These are the steps I follow when trapping events for other applications that I automate; however, its not working for Access forms
Regards
Adam
My overall goal today is to put together a few class we can drop in our new Access (2000) apps. The first of these jewels, the calendar form
I've dropped a calendar control and command button (cmbOk) onto an Access form (frmCal). The form has a custom event BeforeHide(ValueOfCalendarControl As Date), which has a date parameter - the value of the calendar control.
Public Event BeforeHide(ByVal dteDteSel As Date
The event is `raised` when the Ok (cmbOk) button is clicked, which causes the form to become invisible
Private Sub cmbOk_Click(
RaiseEvent BeforeHide(mdteDteSel
Let Me.Visible = Fals
End Su
This form also has 2-methods CloseSelf() and OpenSelf() - code below. CloseSelf() closes the form, and OpenSelf() opens the form
Public Function CloseSelf(
Call DoCmd.Close(acForm, Me.Name
End Functio
Public Function OpenSelf(
Call DoCmd.OpenForm(Me.Name, acNormal
End Functio
For testing purposes, I've made another form (frmTest). I've got a text box on this (test) form, which when double-clicked spawns my nifty calendar modal. I select a date and click the Ok button and the form disappears as expected; however, the test form never receives the date because the BeforeHide() event is never trapped. Here is the code for my test form
Private WithEvents frm As Form_frmCa
Private Sub Form_Load(
Set frm = New Form_frmCa
End Su
Private Sub Form_Unload(Cancel As Integer
Call frm.CloseSel
Set frm = Nothin
End Su
Private Sub frm_BeforeHide(ByVal dteDteSel As Date
Debug.Print "The BeforeHide() event executed!
Let Me.tbDate.Value = CStr(dteDteSel
End Su
Private Sub tbDate_DblClick(Cancel As Integer
Call frm.OpenSel
End Su
These are the steps I follow when trapping events for other applications that I automate; however, its not working for Access forms
Regards
Adam