Changing Tab Page using Combo box

G

Guest

I am trying to change the active Tab Page depending on the item selected from
a Combo Box.

Background:-

I have a main form called frmAddEvaluationStock. On this form is a Combo
Box control called AssetCategoryID which lists such things as Laptop, PC and
Printer.

Also on the main form I have a Tab Control with 3 pages (Laptop_Specs,
PC_Specs and Printer_Specs). On each of these tab pages there is a subform
(frm_Laptop_Specs_Subform, frm_PC_Specs_Subform and
frm_Printer_Specs_Subform).

Request:-

What I would like to do is this. If a user selects Printer from the Combo
Box the Printer_Specs tab page is made the active page.

Hopefully I have explained this well enough for people to understand. Any
help would be appreciated.

Many thanks in advance.

Martyn
 
G

Guest

I just found the answer to this by searching through other posts.

I needed to use this :-

In the AfterUpdate event of the combo-box, place an If...Then using the
following:

Me.TabControlName.Value = 0
Me.TabControlName.Value = 1
Me.TabControlName.Value = 2
etc

Thanks
 
M

Marshall Barton

OU_MartynF said:
I am trying to change the active Tab Page depending on the item selected from
a Combo Box.

Background:-

I have a main form called frmAddEvaluationStock. On this form is a Combo
Box control called AssetCategoryID which lists such things as Laptop, PC and
Printer.

Also on the main form I have a Tab Control with 3 pages (Laptop_Specs,
PC_Specs and Printer_Specs). On each of these tab pages there is a subform
(frm_Laptop_Specs_Subform, frm_PC_Specs_Subform and
frm_Printer_Specs_Subform).

Request:-

What I would like to do is this. If a user selects Printer from the Combo
Box the Printer_Specs tab page is made the active page.


You can do that by using the combo box's AfterUpdate event
to run code that sets the tab control's Value property to
the number of the page you want to select:

Me.tabcontrol = Me.tabcontrol.Pages(Me.AssetCategoryID &
"_Specs").PageIndex

That is highly dependent on the values of the combo box
being part of the Name of the tab pages, so be careful.

OTOH, keep in mind that if you have no other reason for
using the tab control and if the subforms are the same size,
you could eliminate the tab control and just set the subform
control's SourceObject property. With the same caveat about
names, the code could be like:

Me.subformcontrol.SourceObject = "frm_" & Me.AssetCategoryID
& "_Specs_Subform"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top