Connecting Tech Pros Worldwide Forums | Help | Site Map

Overlapping subforms - bringing any one to "top of the stack"

Walt in Decatur's Avatar
Newbie
 
Join Date: Jun 2007
Location: Decatur, Georgia
Posts: 20
#1: Jun 15 '07
I have set up a bunch of subforms to appear in the same spot on the screen relative to the main form. I have set up command buttons with open and close each subform. However, if I have several open at the same time, only the one that is "later" in the order of controls shows, the others sit underneath and one can't set focus on them.

First question. Design-wise, I like the way I've set this up, as one can expect a subform to always pop up in the same spot. But is this a good idea?
Second question. What would be the code for a command button to bring any particular subform to the top, in front of others? Can this be done easily regardless of how many subforms are open at any given time?

Thanks, oh wise Access gurus!

ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,216
#2: Jun 16 '07

re: Overlapping subforms - bringing any one to "top of the stack"


Quote:

Originally Posted by Walt in Decatur

I have set up a bunch of subforms to appear in the same spot on the screen relative to the main form. I have set up command buttons with open and close each subform. However, if I have several open at the same time, only the one that is "later" in the order of controls shows, the others sit underneath and one can't set focus on them.

First question. Design-wise, I like the way I've set this up, as one can expect a subform to always pop up in the same spot. But is this a good idea?
Second question. What would be the code for a command button to bring any particular subform to the top, in front of others? Can this be done easily regardless of how many subforms are open at any given time?

Thanks, oh wise Access gurus!

Let's assume you have 6 stacked Sub-Forms, and you wish to view SubFormTwo. Just set its Visible Property to True and the rest to False, something similar to the code below:

Expand|Select|Wrap|Line Numbers
  1. 'Want to view SubFormTwo
  2. Me!SubFormOne.Visible = False
  3. Me!SubFormTwo.Visible = True
  4. Me!SubFormThree.Visible = False
  5. Me!SubFormFour.Visible = False
  6. Me!SubFormFive.Visible = False
  7. Me!SubFormSix.Visible = False
JKing's Avatar
Moderator
 
Join Date: Jun 2007
Location: Niagara Falls, Ontario
Posts: 557
#3: Jun 18 '07

re: Overlapping subforms - bringing any one to "top of the stack"


If you don't need more than one of the subform open at any one time you could just as easily flip the sourceobject each time you want a different form to appear. This means only having one subform pane on your main form instead of stacking 6 subforms on the same form. All you would have to do is put the correct subform name in for each button click event.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSubForm1_Click()
  2. Me.sfrm.SourceObject = "sfrm1"
  3. End Sub
  4.  
Walt in Decatur's Avatar
Newbie
 
Join Date: Jun 2007
Location: Decatur, Georgia
Posts: 20
#4: Jul 10 '07

re: Overlapping subforms - bringing any one to "top of the stack"


Bingo! Thanks!

This is the way I chose to implement it (now that I got back to working on my form). I think it's the simplest way, indeed. I probably should have thought of this in the first place, but I'm still learning how to exploit properties of various controls to my advantage. Not having any formal training makes for interesting adventures in coding. :-)

Quote:

Originally Posted by JKing

If you don't need more than one of the subform open at any one time you could just as easily flip the sourceobject each time you want a different form to appear. This means only having one subform pane on your main form instead of stacking 6 subforms on the same form. All you would have to do is put the correct subform name in for each button click event.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSubForm1_Click()
  2. Me.sfrm.SourceObject = "sfrm1"
  3. End Sub
  4.  

Reply


Similar Microsoft Access / VBA bytes