954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Identify child forms in MDI app

Hi,

I have a dilema, I have an MDI app and I open new forms as

In modBas.bas:

    Public frmD(50) As frmDocument

MDI Form Load (frmMain):

    Static lDocumentCount As Long
    lDocumentCount = lDocumentCount + 1
    Set frmD(1) = New frmDocument
    frmD(1).Width = 320 * Screen.TwipsPerPixelX
    frmD(1).Caption = "Page - Home (" & lDocumentCount & ")"
    frmD(1).Show
    lDocumentCount = lDocumentCount + 1
    Set frmD(2) = New frmDocument
    frmD(2).Width = 320 * Screen.TwipsPerPixelX
    frmD(2).Caption = "Page - About (" & lDocumentCount & ")"
    frmD(2).Show


I can refer to each form as

frmD(Index).SetFocus
frmD(Index).Show

etc. no problem.

However I cannot read this name from the form, when I read the name:

strFrmName = ActiveForm.Name


I simply get frmDocument (the template document name)

How can I read the frmD(Index) name of the Active Document?

Tried everything I can think of, help much appreaciated.

Steve"If all you own is a hammer, every problem starts looking like a nail."

richosr
Newbie Poster
4 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

Not sure what you mean by "form name". The Name attribute for every child form of the same type will be the same.

One possibility if you're looking for a way to identify the forms is to use the frmD(Index).Tag property and populate it with something useful when you instantiate it. Or, if you're using .Tag for something else, you can always create a hidden textbox control and use that for the same purpose.

BitBlt
Master Poster
711 posts since Feb 2011
Reputation Points: 367
Solved Threads: 109
 

Not sure what you mean by "form name". The Name attribute for every child form of the same type will be the same.

One possibility if you're looking for a way to identify the forms is to use the frmD(Index).Tag property and populate it with something useful when you instantiate it. Or, if you're using .Tag for something else, you can always create a hidden textbox control and use that for the same purpose.

The Tag option seems to be the solution. Thanks for that.

richosr
Newbie Poster
4 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 
The Tag option seems to be the solution. Thanks for that.

For some reason assigning a tag to each frmD(n) doesn't work, so have used your second option, a hidden, disabled,locked label, and that does work, so thanks again.

richosr
Newbie Poster
4 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: