Subforms on a tab control

SteveC24

Registered User.
Local time
Today, 19:16
Joined
Feb 1, 2003
Messages
444
Hello,

I have only recently discovered the ability to put subforms on a tab control, so therefore, cannot figure out how to do this at all!

I have a combo box on my main form, which is set up (using a wizard :eek: ) to find the other data in the form by selecting the combo box data. That made no sense, so here is an example:

You have 20 fish tanks set up in the database, you select the fish tank name from the combo box, and it loads up the measurements you have entered elsewhere in the database into the current view.

What I want to do is to have each of these subforms have a different form in (which I can do), for e.g. one with a list of filters in, one with a list of heaters and so on...

The problem is, when I select the fish tank on the main form, it doesn't change the subforms.
The subforms are setup so they are linked on TankID, which is in both the main form and all the subforms.

If I have made any sense at all, please help, otherwise ask questions and I will try my best to explain!

Thanks!
 
I think this may do the trick.

Private Sub Form_Current()

If Me.cmboFishTankName = "Tank1" Then
Me.tbCtlsfrmDetails1.Pages(0).SetFocus
End If

If Me.cmboFishTankName = "Tank2" Then
Me.tbCtlsfrmDetails1.Pages(1).SetFocus
End If

End Sub

Where cmboFishTankName is the name of your combo where you choose the tank. tbCtlsfrmDetails1 is the name of the tab control on your subform. Pages(0) and Pages (1) are the page numbers where you will find the different forms.

If you would like me to explain further, post back.

ps, where abouts in Kent are you?
 
Hello

I am just outside Tunbridge Wells. Small world!

I think, if I am reading it correctly, that code you supplied will change which page of the tab control is displayed dependant on which tank is selected.

This isn't quite what I was after. For EACH tank, there needs to be all the tabs. So, for Tank 1, there should be tabs for filters, heaters etc.

I want it to work like any normal subform would, except with many subforms in a tab control instead of all spread out.

Again, this one makes no sense...hope you understand!
 
Sorry, I was being really thick.

After I used the wizard ( :eek: ) I renamed the combo box, but forgot to change the name in the VB.

Whoops!

Thanks anyway!
 
I assumed before that when you said they didn't change, I thought that they were dependent on what tank was chosen, hence my reply. Glad you've got it sorted now.
 

Users who are viewing this thread

Back
Top Bottom