A couple lingering multiple form instances questions

M

Max Moor

Hi All,

I've created a collection for storing instances of the form I want to
open multiple copies of. I've placed the collection in the module for my
LeftNav form. This form is the first opened by the program when it boots,
never closes, and is always visible until the program is shut down. All
the code that manages my visible forms is already in there. Is there a
reason to put the "multi-form" collection in a module of its own in this
circumstance?

The bigger question is about manipulating one of these forms. The
main thing I need to be able to do is to make one of them be the top form,
the one with the focus.

On a regular form, I'd call DoCmd.SelectObject "<FormName>". For the
multi-forms, they all have the same name, So that won't work, but I have
the form object reference in the collection.

Borrowing a code fragment from Allen Browne's site, I think I could do
this:

' The collection's items are Form objects
Public clnClient As New Collection

' Each form's window handle is used as the item key in the collection
Function SetRegisterWindowFocus (hWnd As Long)

Dim obj As Object

For Each obj In clnClient
If obj.Hwnd = CStr(hWnd) Then

obj.SetFocus

Exit For
End If
Next
End Function

On the face of it, this makes sense to me. Am I even close? :)

Regards,
Max
 
M

Max Moor

Hi Again,

I ultimately got far enough to answer my own questions. First off,
having the collection in the module for the LeftNav works fine.

Also, I finally ccame to understand collections well enough to realize
that a statement like:

clnClient.Item("MyKeyString")

returns a form object, so I can run any of the form methods, like:

clnClient.Item("MyKeyString").SetFocus

Nice.

Regards,
Max
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top