Tick a checkbox, unhide a tabpage

T

Travis

I'm creating a form where I want to select certain functionality with a
checkbox. When that checkbox is ticked, I want a new page to become
unhidden on a tab control.

I've never tried to program tab pages before so I don't know how to
refer to the tab page object etc.

Does anyone know of any handy references to some code for hiding and
unhiding controls, particularly tab pages?

Thanks

Travis
 
G

Guest

You can reference the individual page of a tab control in a couple of ways:
1. Use the Page Indes property:
Me.TabCtl8.Pages(1).Visible = True
2. Use the Name property of the Page:
Me.PageName.Visible = True
Placing this code (using the Page Index property) in the After Update event
of the check box will caluse the page to be visible when the check box if
checked and not visible when the check box is unchecked. (Note: You could
also change the Caption property of the check box when checked or not checked
by placing a line in the IF statement like: me.ChkBxLabelName.caption =
"Some Text ...")

if me.chkBoxName = true then
Me.TabCtl8.Pages(1).Visible = true
else
Me.TabCtl8.Pages(1).Visible = false
end if

The "chkBoxName" must be the actual name of your check box.
The "TabCtl8" must be the actual name of your tab control.
The "Pages" value is the value from the "Page Index" property of the
specific page of your tab control.
 
T

Travis

Thanks Mr B, I got it working!

The Me. keyword didn't work because I was using a subform on the first
tab page and therefore the tab page wasn't an object of Me. But when I
used Forms!Formname instead it worked fine.

Thanks very much!

Travis
 
G

Guest

All of your opservations would be correct when a sub form is involved. I did
not realize that you were using a sub form.

Good luck with your development

Mr B
 
T

Travis

One problem is that when I go to the next record, the tab pages are
still visible as set by the previous record. Of course I can click my
way down the checklist and every click will set it up the way I want,
but some would have to be clicked twice.

When I'm going to the next record, I want the tabs to be made visible
or invisible according to the checkbox settings chosen in the visible
record. What the click settings were for the previous record is of no
interest.

So what event should I use as the trigger to run the subs again? None
of the events (on click etc) seem to fit.

Travis
 
R

Rick Brandt

Travis said:
One problem is that when I go to the next record, the tab pages are
still visible as set by the previous record. Of course I can click my
way down the checklist and every click will set it up the way I want,
but some would have to be clicked twice.

When I'm going to the next record, I want the tabs to be made visible
or invisible according to the checkbox settings chosen in the visible
record. What the click settings were for the previous record is of no
interest.

So what event should I use as the trigger to run the subs again? None
of the events (on click etc) seem to fit.

Travis

The Current event of the form runs every time you change records. Repeat (or
call) your code there as well.
 

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