WithEvents subform

ClaraBarton

Registered User.
Local time
Today, 13:29
Joined
Oct 14, 2019
Messages
778
I have a main form with a subform.

Code:
Private WithEvents subFrm As Access.Form

Private Sub Form_Open(Cancel As Integer)
   ' set withevents variable to the subform object
   Set subFrm = Me.fsubDetail.Form
   ' ensure subform object raises Current event
   subFrm.OnCurrent = "[Event Procedure]"
End Sub
When the current event runs on the subform, I want a control on the parent form to become active but It can't seem to find it.
Since this code is on the parent form, how should the following code be addressed:
Code:
Private Sub subFrm_Current()
 On Error GoTo errlbl
 Dim strKey As String

   strKey = "IT" & Me.ItemID
       TVW.TreeView.Nodes(strKey).Selected = True  'Element not found
       TVW.TreeView.SelectedItem.EnsureVisible
       TVW.TreeView.DropHighlight = Me.TVW.SelectedNode

  Exit Sub
I've tried Me.Parent...
and Form.MainForm...
neither works
 
AARRGH!!! Do you know how long I've been staring and messing with this? Thank you so much!!!
 
This works because the main form is only a treeview for selecting records. The only change is changing the focus.
 

Users who are viewing this thread

Back
Top Bottom