Tapping Custom Event from Form

G

Guest

All

I've got this nifty form with a calendar control and an Ok button - picture that. The form that contains these controls has a public event that I added, BeforeHide(ValueOfDateControl). This event is kicked off when the user clicks the Ok button on the form. Before the form sets its visibility to false (invisible) it raises the event. The problem is, it isn't raising the event, and I don't know why. Below you can see the code I've used for the calendar form. I've also included the code I'm using for the code I'm using for the form calling the calendar for. Tips would be appreciated - especially on a Sunday

Regards
Ada

###########
# Calendar For
###########

Private mdteDteSel As Dat

Public Event BeforeHide(ByVal dteDteSel As Date

Public Property Get SelectedDate() As Dat
Let SelectedDate = mdteDteSe
End Propert

Public Property Let SelectedDate(ByVal dteNewVal As Date
Let mdteDteSel = dteNewVa
End Propert

Private Sub calDteSel_AfterUpdate(
Let mdteDteSel = Me.calDteSel.Valu
End Su

Private Sub cmbOk_Click(
RaiseEvent BeforeHide(mdteDteSel

Let Me.Visible = Fals
End Su

Public Function CloseSelf(
Call DoCmd.Close(acForm, Me.Name
End Functio

Public Function OpenSelf(
Call DoCmd.OpenForm(Me.Name, acNormal
End Functio

###########
# Calling For
###########

Option Compare Databas
Option Explici

Private WithEvents frm As Form_frmCa
Private WithEvents mail As mai

Private Sub Form_Load(
Set frm = New Form_frmCa
Set mail = New mai
End Su

Private Sub Form_Unload(Cancel As Integer
Call frm.CloseSel
Set frm = Nothin

Set mail = Nothin
End Su

Private Sub frm_BeforeHide(ByVal dteDteSel As Date
Debug.Print "Is executing
Let Me.Text0.Value = CStr(dteDteSel
End Su

Private Sub mail_BeforeMessageDisplay(
Debug.Print "The mail message is about to display!
End Su

Private Sub tbDate_DblClick(Cancel As Integer
Call frm.OpenSel
End Su

Private Sub tbMailTo_DblClick(Cancel As Integer
Let mail.Receiver = tbMailTo.Tex
Call mail.Displa
End Sub
 
P

Pavel Romashkin

It seems to me that in the main form you are not tracking events from
the right calendar form instance:

Set frm = New Form_frmCal

makes a new instance of the calendar form. If you had it open already,
its events will not be tracked by the caller. Instead, try

Set frm = Forms!Form_frmCal

Pavel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top