Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2005, 11:41 AM
David W. Fenton
Guest
 
Posts: n/a
Default Selecting forms with multiple instances

I'm blanking out on this one.

In an old applicaiton, I am implementing a new feature to allow the
user to open multiple instances of a main form. I've got that
working, using the code for this from the Access Developers Handbook
(which I've used successfully many times in the past).

Now, the problem I'm having is that when I close the second
instance, the focus is not necessarily going back to the original
form.

DoCmd.SelectObject can't work because it requires a form name and
all forms have the same name, of course.

Is there a way to select a form by index? I do know the index in the
form's collection, because I'm storing it in a global variable for
the original form.

Any ideas?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
  #2  
Old November 13th, 2005, 11:41 AM
Douglas J. Steele
Guest
 
Posts: n/a
Default Re: Selecting forms with multiple instances

Take a look at what Allen Browne has at
http://www.allenbrowne.com/ser-35.html

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"David W. Fenton" <dXXXfenton@bway.net.invalid> wrote in message
news:Xns966FCED3D6066dfentonbwaynetinvali@24.168.1 28.74...[color=blue]
> I'm blanking out on this one.
>
> In an old applicaiton, I am implementing a new feature to allow the
> user to open multiple instances of a main form. I've got that
> working, using the code for this from the Access Developers Handbook
> (which I've used successfully many times in the past).
>
> Now, the problem I'm having is that when I close the second
> instance, the focus is not necessarily going back to the original
> form.
>
> DoCmd.SelectObject can't work because it requires a form name and
> all forms have the same name, of course.
>
> Is there a way to select a form by index? I do know the index in the
> form's collection, because I'm storing it in a global variable for
> the original form.
>
> Any ideas?
>
> --
> David W. Fenton http://www.bway.net/~dfenton
> dfenton at bway dot net http://www.bway.net/~dfassoc[/color]


  #3  
Old November 13th, 2005, 11:41 AM
Allen Browne
Guest
 
Posts: n/a
Default Re: Selecting forms with multiple instances

Yes, we suggest using the form's hWnd as the index of the collection.

You can then loop through the Forms collection, and find the instance that
has the hWnd, and then Forms(i).SetFocus

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:YI2dnRP8CrwnBDrfRVn-3g@rogers.com...[color=blue]
> Take a look at what Allen Browne has at
> http://www.allenbrowne.com/ser-35.html
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "David W. Fenton" <dXXXfenton@bway.net.invalid> wrote in message
> news:Xns966FCED3D6066dfentonbwaynetinvali@24.168.1 28.74...[color=green]
>> I'm blanking out on this one.
>>
>> In an old applicaiton, I am implementing a new feature to allow the
>> user to open multiple instances of a main form. I've got that
>> working, using the code for this from the Access Developers Handbook
>> (which I've used successfully many times in the past).
>>
>> Now, the problem I'm having is that when I close the second
>> instance, the focus is not necessarily going back to the original
>> form.
>>
>> DoCmd.SelectObject can't work because it requires a form name and
>> all forms have the same name, of course.
>>
>> Is there a way to select a form by index? I do know the index in the
>> form's collection, because I'm storing it in a global variable for
>> the original form.
>>
>> Any ideas?
>>
>> --
>> David W. Fenton http://www.bway.net/~dfenton
>> dfenton at bway dot net http://www.bway.net/~dfassoc[/color][/color]


  #4  
Old November 13th, 2005, 11:42 AM
lylefair@yahoo.ca
Guest
 
Posts: n/a
Default Re: Selecting forms with multiple instances

Dim aForms(1 To 10) As [Form_MDAC and ESO]

Sub CreateInstances()
Dim z As Long
For z = LBound(aForms) To UBound(aForms)
Set aForms(z) = New [Form_MDAC and ESO]
aForms(z).Caption = aForms(z).Caption & "_" & z
aForms(z).Visible = True
Next z
DoCmd.RunCommand acCmdWindowCascade
End Sub

Sub RemoveInstances()
Erase aForms
End Sub

  #5  
Old November 13th, 2005, 11:42 AM
David W. Fenton
Guest
 
Posts: n/a
Default Re: Selecting forms with multiple instances

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in
news:YI2dnRP8CrwnBDrfRVn-3g@rogers.com:
[color=blue]
> Take a look at what Allen Browne has at
> http://www.allenbrowne.com/ser-35.html[/color]

That just duplicates the same code as in ADH, though it's simpler
and more clearly presented!

I later determined that the problem was that I wasn't cleaning up
the collection, because of an incomplete implementation of the code
copied from the last app where I used it. I got tired and gave up
before solving it, but at least know where my problem is.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
  #6  
Old November 13th, 2005, 11:42 AM
David W. Fenton
Guest
 
Posts: n/a
Default Re: Selecting forms with multiple instances

"lylefair@yahoo.ca" <lylefair@yahoo.ca> wrote in
news:1118312650.387109.254160@o13g2000cwo.googlegr oups.com:
[color=blue]
> Dim aForms(1 To 10) As [Form_MDAC and ESO]
>
> Sub CreateInstances()
> Dim z As Long
> For z = LBound(aForms) To UBound(aForms)
> Set aForms(z) = New [Form_MDAC and ESO]
> aForms(z).Caption = aForms(z).Caption & "_" & z
> aForms(z).Visible = True
> Next z
> DoCmd.RunCommand acCmdWindowCascade
> End Sub
>
> Sub RemoveInstances()
> Erase aForms
> End Sub[/color]

Did anyone actually read my question before answering with things I
was already doing?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles