Results 1 to 7 of 7
  1. #1
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    I have read Post 565662, and seen the link that points to MS KB :How to Open multiple instances of the same form

    The examples all seem to involve opening a second instance from the form itself. That is not what I have been asked to do.

    From a continuous form, the user selects a record, then clicks a button to open a second form at the selected record.

    Code:
     
    		   If Not IsNull(Me.PracticeID) Then
    					stLinkCriteria = "[PracticeID]=" & Me![PracticeID]
    			End If
    			stDocName = "frmPracticeDetails"
    			DoCmd.OpenForm stDocName, , , stLinkCriteria
    They would like to be able to leave frmPracticeDetails open, return (somehow) to the list form, select another Practice and view its details.
    Returning to the continuous form, selecting a different record and clicking the button a second time does not work (I did not expect it to). frmPracticeDetails then shows the details of the second practice, but the first practice is now gone.

    I tried this.

    Code:
    	If Not isLoaded(stDocName) Then
    			   DoCmd.OpenForm stDocName, , , stLinkCriteria
    		   Else
    			   Dim frmPracticeDetailsx As Form
    			   Set frmPracticeDetailsx = New Form_frmPracticeDetails
    			   frmPracticeDetailsx.Filter = stLinkCriteria
    			   frmPracticeDetailsx.FilterOn = True
    			   frmPracticeDetailsx.SetFocus
    		   End If
    If the form is already open when the button is clicked, a form flashes up briefly but closes immediately and I am left at the list.

    • Can you do what I want?
    • If so does it involve something much more complicated than what I have tried above?
    Regards
    John



  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I have attached a small sample database based on Allen Browne's Managing Multiple Instances of a Form, modified to demonstrate how to open a filtered form.

    Open frmClientSearch and click the "Show selected client" button to open an instance of the other form frmClient for the selected client.
    Each new form will be offset slightly from the previous one, eventually it will disappear from the screen.
    Clicking "Close detail windows" closes the forms and resets the position.

    There is no check against opening multiple windows on the same record.
    Attached Files Attached Files

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I forgot to mention that the essential part is adding the form object of the new instance to a collection. This keeps the form open after the event procedure has finished. As you can see in CloseAllClients, removing the object from the collection instantly closes the instance.

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Thanks for these two posts Hans. I have just downloaded the demo, and will look at it in depth.
    Regards
    John



  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I have attached a slightly modified version that prevents opening multiple instances for the same ClientID. If there is already an instance for the selected ClientID, that form is activated.
    Attached Files Attached Files

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Thanks for all this. I have been able to get it to work.

    A few issues arose (not surprisingly).

    • The Forms![frmPracticeDetails]![PracticeID] syntax can't be used. frmPracticeDetails has some subforms with combo boxes, so I had to set the row source dynamically to an sql string.
    • Access seems happy for multiple instances of the subforms to be open at the same time, with the combo boxes having different row sources. I had thought that might create a problem.
    • frmPracticeDetails is quite large and has a number of subforms. My preference is to maximize it, but I need to be able to see the list of practices. Making frmPracticeDetails a popup form works well visually, but I actually need to be able to open other forms in front of frmPracticeDetails (e.g. they need to be able to look at the Doctors at the Practice for example)
    • So the result of all this a visual jumble on the screen. I don't like it at all, but I will give it a go.
    Thanks again
    Regards
    John



  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    I have now reverted to keeping all the forms maximized, and made a few changes to support this.
    I will try this out tomorrow with the users and see what they think.
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •