Tab control pages

Bee

Registered User.
Local time
Today, 00:51
Joined
Aug 1, 2006
Messages
486
Hi,


I want to open up a certain page of a tab control using VBA code.

For example: when user presses a button in a form, tab number three of a tab control opens in an other form.

Any help will be very much appreciated.
B
 
There's a docmd and a macro to go to a named tab.
 
In VBA, simply set the value of Tab Control to whatever the Index of the Tab you want.

Code:
TabCtl10 = 0 'The Index value of First Tab

The Index property can be modified in Other tab on the control properties.
 
Banana said:
In VBA, simply set the value of Tab Control to whatever the Index of the Tab you want.

Code:
TabCtl10 = 0 'The Index value of First Tab

The Index property can be modified in Other tab on the control properties.
How would I reference the form where the tab is?
I tried:

Code:
myTabControlName.Index = 2

but it returns the following message: 'Object required'
 
1) Is that form open or will it be?

2) If you're doing it from another form-
Code:
Forms!MyForm!MyTabControl
 
Banana said:
1) Is that form open or will it be?

2) If you're doing it from another form-
Code:
Forms!MyForm!MyTabControl
The form will open when user presses a button. The only thing different is that instead of opening showing the default tab( first tab) on the tabcontrol, it will show a different tab.

Thanks,
B
 
Just so I'm sure, you got it to work now?
 
Banana said:
Just so I'm sure, you got it to work now?
Not yet actually, I am having some trouble with something else. Posted under(Call procedure on a different form).

I will try to get it to work sometime today.

Thanks for your help,
B
 
Banana said:
Just so I'm sure, you got it to work now?
it returns a compilation error. "expected ="

I wrote it this way:
Code:
Forms!Customer!CustTab

however, it did not work.
 
Right. It's asking for an Index

Look at your tab's properties to get the Index number. It's in "Other" tab.

With my tabs, if I wanted to go to my first tab, it usually defaults to 0, second is 1, third is 2, so going to first tab,

Code:
Forms!MyFormName!TabCtl10 = 0

and to go to second tab,

Code:
Forms!MyFormName!TabCtl10 = 1
 
Banana said:
Right. It's asking for an Index

Look at your tab's properties to get the Index number. It's in "Other" tab.

With my tabs, if I wanted to go to my first tab, it usually defaults to 0, second is 1, third is 2, so going to first tab,

Code:
Forms!MyFormName!TabCtl10 = 0

and to go to second tab,

Code:
Forms!MyFormName!TabCtl10 = 1
it cannot find my form for some reason!

I am calling form frmCustomer from another form called frmMain.
 
Are you sure you have all names correct?

Your code above didn't have the "frm" prefix.
 
This will work too.

I have a form that has a tab control (named tabMyTabControlName) and there are three tabs named Customer, Business, and Address. If I want to open the form and select the Address tab the code is:

Code:
   DoCmd.OpenForm "frmCustomer", acNormal
    Forms!frmCustomer.tabMyTabControlName.Pages("Address").SetFocus
 
boblarson said:
This will work too.

I have a form that has a tab control (named tabMyTabControlName) and there are three tabs named Customer, Business, and Address. If I want to open the form and select the Address tab the code is:

Code:
   DoCmd.OpenForm "frmCustomer", acNormal
    Forms!frmCustomer.tabMyTabControlName.Pages("Address").SetFocus
Excellent. It's working now. Thanks very much guys.
 
Hi folks,

I am trying to save the value of a field of a subform that's located on a tab control on a main form.

Main form: frmHouse
Tab control: tabHouse
Sub form: subListedBuildingConsent
The field value I want to save: Applied

I tried this code, but I got errors.

Code:
vApplied = Forms![frmHouse].tabHouse.Pages("subListedBuildingConsent").Form![Applied]

Any help will be very much appreciated
B
 
Bee-

You don't reference the tab control at all. When using the tab control and referencing other controls on it, it's just as if the tab control didn't exist. So, you would just reference your subform as normal:

Forms!YourMainFormNameHere.YourSubformContainerNameHere.Form.YourControlNameHere

vApplied = Forms!frmHouse.YourSubformContainerNameHere.Form.Applied
 
A tab is merely a control on a form, it's never part of the address to another control, only to itself.

boblarson gave you the corrrect reference.
 
Why not reference the sub form directly Forms!MainForm!Subform!Control = Value Of Applied

That will add the value to the subform you don't need worry bout the tabs as the subform will be in the contols collection of the main form that is if it's on the main form.

If you need to save the record for other use Then Try

Form!MainForm!Subform.Form.Requery

That will force the date to be saved on the subform

Hope it helps

Mick
 
Last edited:

Users who are viewing this thread

Back
Top Bottom