Custom class does not capture event

M

Mario Osorio

============================================================
class clsMorForm
============================================================
Option Compare Database
Option Explicit

Dim WithEvents frm As Form
Public Controls As Collection

Property Set Form(TheForm As Form)
Dim ctl As Control
Dim morCtl As clsMorControl

Set frm = TheForm
Set Me.Controls = New Collection

For Each ctl In frm.Controls
If ctl.ControlType = acTextBox _
Or ctl.ControlType = acListBox _
Or ctl.ControlType = acComboBox _
Or ctl.ControlType = acAttachment Then
Set morCtl = New clsMorControl
Set morCtl.Control = ctl
Controls.Add morCtl
End If
Next ctl
frm.BeforeUpdate = EventProcedure
End Property

Private Sub frm_BeforeUpdate(Cancel As Integer)
MsgBox "frm_BeforeUpdate"
End Sub

============================================================
class Form_frmPatients
============================================================
Option Compare Database
Option Explicit

Private Sub Form_Load()
Dim morForm As clsMorForm

Set morForm = New clsMorForm
Set morForm.Form = Me.Form
End Sub

Private Sub Patient_AfterUpdate()
Me.Patient = StrConv(Me.Patient, vbProperCase)
End Sub

============================================================
Module modOtherConstants
============================================================
Option Compare Database
Option Explicit

Public Const EventProcedure = "[Event Procedure]"

============================================================
============================================================
I haven't used Access/VBA in quite a while and this is driving me nuts: The event I am trying to sink is not working, it just does not happen. What am I doing wrong here?!?

Any and all comments area welcome.
TIA!
 

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