Using API and determining the form's internal ID number is way overkill. Just make up your own unique identifier for the forms, (like, say, the treeview node's .Key property) and stuff that into the forms' .Tag property.Code:Option Explicit Private Sub Command1_Click() Dim frm As Form If Not Treeview1.SelectedItem Is Nothing Then Set frm = New Form2 frm.Tag = Treeview1.SelectedItem.Key frm.Show Set frm = Nothing End If End Sub Private Sub Command2_Click() Dim frm As Form For Each frm In Forms If frm.Tag = [some value] Then frm.Show Next Set frm = Nothing End Sub




Reply With Quote