linking combo box to tab controls

Cindy

Registered User.
Local time
Today, 05:18
Joined
Jul 3, 2014
Messages
160
Hi there, sorry my VB skills are not strong and I need some help on how to go about this. :confused: On my data entry Form, I have a Combo Box [Condition] and five tab controls. Each tab has as many as 10 controls on it. The purpose of the Form is to populate a table. My questions are:

1) Do I still need to use a subform on each Tab or leave them as-is? i.e.
the 10 controls are on each tab

2) How do I make the value of [Condition] transfer focus to the
appropriate tab??

your help is greatly appreciated
 
1. It depends on your setup. If you're using fields from only one table and you're using the tabs just to spread things out then you don't need subforms. On the other hand if some controls on some tabs are pulling data from another table then you need a subform.

2. "Value of [Condition]"? Please elaborate.
 
Hi vbaInet. Thanks for your feedback. I have only one Table. My combo box has Table.[condition] as its row source. So in the drop down menu, the values are Pregnant, PreTerm Labour, Pre Eclampsia, On Route delivery and PPH.

I tried to add a subform (with "raised" effect) to the Tab but it covered all the controls already there and I could not change the background colour to match the tab either. Any tips on getting around this? otherwise I'll just jettison the subform altogether?
 
Ok,

1. Is your table actually called "Table" or it's called "Table.[Condition]"?
2. Let me see a screenshot of what you're talking about.
 
no my table is called Obstetrics. I have tried to attach a screen shot. my project is to create a database with Access that will contain historical data which will be analysed from time to time.

When the user clicks on condition field on the form, I want the corresponding tab to be 'opened'.
 
If your table is called Obstetrics, what is the meaning of Table.Condition? I still don't understand what you meant.

The screenshot didn't attach. When you click Upload you need to wait for it to upload.
 
so actually it is Obstetrics.[Condition] not Table.[Condition]. I'll try and attach it again
 

Attachments

  • doc1.jpg
    doc1.jpg
    50.9 KB · Views: 87
I'm trying to understand the ".Condition" part. What's it for?

And what is the subform issue? I don't see it on your screenshot.
 
The condition is a field on the Obstetrics table. It is also a control on my form. When I select from the value list, I want the corresponding Tab form to open up.
As for the subform, I clicked it on the tab page but it covered what was already on it . When I pasted the other controls on it, they were hidden from view. Not sure how to fix that:confused:
 

Attachments

  • doc2.jpg
    doc2.jpg
    69.5 KB · Views: 77
Alright, I get you now! I would imagine what you meant is Condition is the Control Source not the Row Source.

What values do you have as the ID field in your combo box? In most cases this would be the first field in the Row Source.

A subform will always sit on top.
 
sorry didn't understand the question. Are you referring to the patient ID fields or the "Condition" field?

Condition combo box contains: Pregnant, PreTerm Labour, Pre Eclampsia, On Route delivery and PPH.

I want the user's selection (in Condition), drive which Tab page comes to the fore, or loads. Could you advise on how I can go about this please?
 
I want the user's selection (in Condition), drive which Tab page comes to the fore, or loads. Could you advise on how I can go about this please?
I already understand the plight. We'll get to that when I have all the necessary information.

Now that I know the values, what are the names of the fields contained in the Row Source of your combo box? Listed in order.
 
I'm not usually slow but I'm not sure if I understood the question. My combo box has only one column - just the values. Are you referring to the record in my table (i.e. the columns names)? If so, they are too many to list. There are more than 30 columns and each one has a long name...

examples are: anti_hypertensive_agent, regular_blood_pressure, Preterm medication given
 
If it's a combo box bound to a table in most cases you would have at least two fields. Anyway, let's not worry about that.

Is the order of the values in the combo box the same as the order in which the tabs are laid out? That is:
Pregnant - open page 1
PreTerm Labour - open page 2
Pre Eclampsia - open page 3
On Route delivery - open page 4
PPH - open page 5
 
Hi vbaInet, yes they are listed in the same order
 
Ok, it's a very simple piece of code:
Code:
Me.[COLOR="Blue"]TabControlName[/COLOR].Pages(Me.[COLOR="blue"]ComboBoxName[/COLOR].ListIndex).SetFocus
The highlighted bits are what you need to amend. And ensure that the Page Index property of the pages begins from 0.
 
Hi vbaInet, thank you very much for the code. However I entered the code in the Combo Box's AfterUpdate event but it gave me a compile error.:banghead: Please see the attached and advise.
 

Attachments

  • doc3.jpg
    doc3.jpg
    94.8 KB · Views: 73
That's not the name of the tab control Cindy. A tab control contains pages. You are probably referring to the page and not the tab ;)

But kudos for knowing what event it should go into though!
 
By the way, my opinion on your design is that the use of a combo box for selecting just 5 tabs is a bit unnecessary. If you had so many tabs that are hard to read then it definitely makes sense, but if the tabs are clearly labelled they can just be clicked. Perhaps you've got reasons why you're doing this? Care to share?
 
excellent! it worked. Thank you!!
hm who knows why I chose that design, vanity maybe.:D Actually I have 13 other tables (plus forms) to create and populate so you just gave me an idea. The thought of going through this 13 more times is scaring me. P'raps I should just tweak this form and use it for the 13 tables. Just that the tabs will end up being about 20. Isn't that going to cause performance issues?
 

Users who are viewing this thread

Back
Top Bottom