REPOST: Bug in tab control? Access 2007


T

Tieske

Hi Maurice,

thanks for your response. Took me a while to reproduce, but by now, I think
I know what the problem is. The caveat is the dynamic number of pages.

to reproduce take the following steps;
1) empty database
2) create form named "Form1"
- set form popup to yes.
- put a tabcontrol in there, covering most of the detail section
- Set the anchoring of the tabctrl to strech across and down
- multiline to true
- On the first tab page add a textbox, covering the whole tabpage
- Set anchoring for the textbox also to stretch across and down
- Close and save the form
3) create another form named "Form2", leave it empty, but add the following
code for the Open and Close events and close and save this form as well;

Option Compare Database
Option Explicit

Const strFormName = "Form1"
Const strTabLabel = "ExtraTab"

Private Sub Form_Open(Cancel As Integer)
Dim frm As Form
Dim tabctrl As TabControl
Dim tabpage As Page
Dim ctrl As Control
Dim n As Long

' open form in design mode to make changes
DoCmd.OpenForm strFormName, acDesign
Set frm = Forms(strFormName)
frm.PopUp = True ' set form as popup
For Each ctrl In frm.Controls ' go get tab control
If ctrl.ControlType = acTabCtl Then Set tabctrl = ctrl
Next
If tabctrl Is Nothing Then ' tab-control not found
MsgBox "Couldn't find a tab control on the form"
Exit Sub
End If
tabctrl.MultiRow = True ' set tab to multiline
For n = 1 To 10 ' Add a whole set of tabs
Set tabpage = CreateControl(strFormName, acPage, tabctrl.Section,
tabctrl.Name)
tabpage.Name = strTabLabel & n
tabpage.Caption = "Extra long tab caption to show multiline"
Next n
DoCmd.Close acForm, strFormName, acSaveYes ' Close and save changes
DoCmd.OpenForm strFormName, acNormal ' Open form for user
End Sub
Private Sub Form_Close()
Dim frm As Form
Dim ctrl As Control
Dim n As Long

' make sure to close form
DoCmd.Close acForm, strFormName, acSaveYes
' open form in design mode to make changes
DoCmd.OpenForm strFormName, acDesign
Set frm = Forms(strFormName)
For n = frm.Controls.Count - 1 To 0 Step -1 ' Remove a whole set of tabs
If Left(frm.Controls(n).Name, Len(strTabLabel)) = strTabLabel Then
' found a previously added one, so delete it
DeleteControl strFormName, frm.Controls(n).Name
End If
Next n
DoCmd.Close acForm, strFormName, acSaveYes ' Close and save changes
End Sub

4) open "Form2". The code will add a whole number of pages to "Form1" and
will then show "Form1"
5) the textbox on "Form1" is now partly or fully obscured by the tabs of the
tabcontrol

it looks as if the size of the tab-page in calculated incorrectly, so
placing the controls on the page (and sizing them) should only happen after
the correct size of the page has been calculated. eg. the
strechdown-and-across of the textbox seems to precede the drawing of the
tabs.
This scenario could interfere altogether with the sizing. The stretching of
controls is based upon a minimum size of the forms and then GROWING them
along with the form (shrinking it results in scrollbars). In this case the
actual space available for drawing controls on a page is reduced because of
the extra line of tabs that needs to be drawn, and this would in a worst
case
scenario lead to controls being SHRINKED to fit. Which is not the way the
whole thing was designed.

so far my analysis. Hope it helps to reproduce. Any ideas on how to
circumvent it?

Regards,
Tieske
 
Ad

Advertisements

M

Maurice

Hi Tieske,

I was able to reproduce what you were talking about. My guess would be that
the combination of the pop-up setting in combination with the anchoring us
causing the troubles. I've just about tried every possible cobination there
is and as long as the form is not maximized I get the same results. Only when
playing around with anchoring or rather setting these options in the various
combinations I get some results but not the results you are looking for. So
in answer to you comments yes this is a caveat and migth cause trouble. The
only way to work around this is placing the controls in the position you want
them to be and not make the form sizable. I don't thin it's the tabcontrol
thats 'bugging' it in my opinion it's the pop-up in combination with the
anchoring..
 

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