By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,019 Members | 1,435 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,019 IT Pros & Developers. It's quick & easy.

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

Walt in Decatur
P: 20
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!
Jun 15 '07 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,706
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
Jun 15 '07 #2

JKing
Expert 100+
P: 1,206
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.  
Jun 18 '07 #3

Walt in Decatur
P: 20
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. :-)

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.  
Jul 10 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.