Using multiple instances of a subform on tabbed forms (1 Viewer)

jillrein

Registered User.
Local time
Today, 01:43
Joined
Apr 19, 2008
Messages
28
I have a form where the user enters a day. There is a tabbed form below where each tab contains the same subform. The tabs show the names of classes running on that day. The subforms are populated by a query that selects all students enrolled on classes running that day. What I want to do is to apply a different filter on each tab so that only students on that particular class show on the relevant tab.

Do I have to create a different subform for each tab or is there a way I can use the same form but apply a different filter to each instance of it?

If I do have to create different subforms, can I make them into an array so that I can refer to them in various loops that loop through each tab in turn?

I hope this makes some kind of sense. :confused: Any pointers will be much appreciated
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:43
Joined
Sep 12, 2006
Messages
15,662
why have multiple tabs - if you have multiple tabs, you can only see one at a time

why not just have a drop down on the main form, select the class you want, and requery the single subform to reflect the selected class
 

jillrein

Registered User.
Local time
Today, 01:43
Joined
Apr 19, 2008
Messages
28
I could do, but this way means that all class names can be seen on the screen at one time and user can flick between them to register people as they arrive. Your suggestion is my fall back position if I can't make plan 1 work.
 

datAdrenaline

AWF VIP
Local time
Today, 03:43
Joined
Jun 23, 2008
Messages
697
If you like that presentation style of the Tab Control that is fine, but I would suggest that you only use ONE sub-form control, just as Gemma suggested, but with a bit of a twist....Don't place the sub-form control IN a tab on the TabControl .. but place the sub-from control OVER the tab control. Then use the OnChange even of the tab control to modify the RecordSource of the SubForm controls Source Object form.

....

But ... I will say that a slight modification of Gemma's suggestion is virtually the same as a tab control can if you use the combo control to drop down a list of days, and use that control as a Link Master Field ... there is no need for code to requery the sub-form control. I personally would use a ListBox instead of a ComboBox, thus allowing the user to see all the days, then the can do a single click to select the day they wish to view, much like the tab control concept.

....

And even expanding on that ... you could use unbound check boxes and let the users see any combination of days they wish to see ... so you could have a check box for each day, then as the user checks a day, your sub-form would include that day, then a user could select Mon AND Tuesday ....

.....

Just some thoughts ...
 

datAdrenaline

AWF VIP
Local time
Today, 03:43
Joined
Jun 23, 2008
Messages
697
... By the way ... you can create many subform controls on a main form that use the same Form object as the Source Object... But I personally do not like to do that too often...
 

jillrein

Registered User.
Local time
Today, 01:43
Joined
Apr 19, 2008
Messages
28
Thanks for the input. I think your first idea of using the tabbed forms but putting the subform on top of it may be the answer. It solves a couple of other problems as well. I want to use the tabs because I am adding functionality to an existing system and as much as possible want to keep it looking consistent - also it took me ages to work out how to dynamically label the tabs - sad but true - so I have a certain investment in keeping them. As you can probably tell I am a vb novice. Your help is much appreciated.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:43
Joined
Sep 12, 2006
Messages
15,662
its an interesting question then

if you have two examples of the same subform, can they each use different filters - i would say YES, but if you gave me five pounds i would say NO

Truth is i'm really not sure - you would have to try it and see

The thing is the users can only see one subform at a time - so it seems a bit over the top managing five instances of a subform, when you can get the same effect with one instance.

DATs idea of a listbox is good, because you will only ever have 5 or 7 items in the list box, so a list box needs less clicks than a combobox - and DAT again is suggesting only using one subform, but it as the appearance of one form for each tab page, which is a neat idea.
 

DCrake

Remembered
Local time
Today, 09:43
Joined
Jun 8, 2005
Messages
8,632
Instead of using a tab control and placing the sub form on top of the control why not use a tap strip. A tab strip does not have a body to it, it only acts as a file divider. Use the on click of the tab strip to determine the index and set the control source of the subform accordingly.

My other observation is.. what happens if, lets say, you have 10 classes and your tab control/strip looks perfectly fine and you are then told you need another class! not only do you have to redesign your control to add another tab you may need to repostion all your controls to make it more pleasing to the eye.

The logic of using a listbox/combobox is far better as no design changes are required shoulld the list grow / shrink / change.

Pessamism is far more forward thinking the Optimism.

David
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:43
Joined
Sep 12, 2006
Messages
15,662
DC - whats a tab strip? Is that a new A2007 thing?

The OP said she liked the look and feel of the tabbed pages - and having spent time on it, didnt want to scrap it. I thought DATs idea was a neat way of merging two ideas
 

DCrake

Remembered
Local time
Today, 09:43
Joined
Jun 8, 2005
Messages
8,632
Gemma,

A tab strip looks just like a tab control you can add as many tabs as you want. All the tab pages belong to one container. I have knocked up a very simple demo to show you how it works. It is available in 2000 >

One work of caution though, some controls always sit behind the tab strip so you are limited as to what you can see in the tabbed pane area.
 

Attachments

  • TabStripDemo.mdb
    152 KB · Views: 359
Last edited:

jillrein

Registered User.
Local time
Today, 01:43
Joined
Apr 19, 2008
Messages
28
Many thanks for this demo - looks like a great solution - I did not even know tab strips existed before! Clearly I still have a lot to learn and its great to have help from all you experts.
 

Users who are viewing this thread

Top Bottom