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