You have mixed up the form load. This works:
Class1:
Option Compare Database
Option Explicit
Private WithEvents frm As Access.Form
Private Const Evented As String = "[Event Procedure]"
Public Sub Initialize(pFrm As Access.Form)
Set frm = pFrm
frm.OnCurrent = Evented
End Sub
Public Sub Terminate()
Set frm = Nothing
End Sub
Private Sub frm_Current()
MsgBox "OK"
End Sub
Form1:
Option Compare Database
Option Explicit
Private FormCollection As Collection
Private Sub Form_Load()
Dim EventProcedure As Class1
Set EventProcedure = New Class1
Set FormCollection = New Collection
EventProcedure.Initialize Me.Form
FormCollection.Add EventProcedure, Me.Name
Set EventProcedure = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Unload events for all colour value textboxes.
Dim EventProcedure As Class1
For Each EventProcedure In FormCollection
EventProcedure.Terminate
Next
Set EventProcedure = Nothing
Set FormCollection = Nothing
End Sub
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…