Raising an Event from a subform
Posted on 2006-06-10
What's the trick to raise an event from a subform? I'm trying to open a secondary form after a button click on a subform. The event should pass an index number to the newly opened secondary form. The form is opening, but there's no index number. I've added the same code to a button on the primary form (the one with the subform), and that works. So I'm left thinking there's some trick to working with the subform.
By the way, if I watch the code in the debugger, the RaiseEvent method appears not to work. There's no error; it just stops on the line with the secondary form open.
From the subform:
Public Event NewMeeting(varMeetingID as Variant)
Within the button's code:
From the secondary form:
Dim varMeetingID As Variant
Dim WithEvents frmMtg As Form_frmsubform
Private Sub Form_Load()
Set frmMtg = Form_subform
Private Sub frmMtg_NewMeeting(varID As Variant)
varMeetingID = varID
If IsNothing(varID) Then
Me.Visible = False
Me.Filter = "MeetingID = " & varID
Me.FilterOn = True
Me.MeetingID.DefaultValue = "'" & varID & "'"
Me.Visible = True