Bug in tab control? Access 2007

T

Tieske

A designed a form using a tab control. As I have quite a lot of tabs I set
the multirow property to true, so instead of the scroll buttons I would get 2
rows of tabs.

All works fine, but in the final stage, I changed the form to a popup form.
Now all of a sudden the top area of my tab-page gets obscured by the second
row of tabs.

anyone familiair with this behaviour? tips on how to resolve this?
(btw: the number of tabs is dynamic, so just moving all controls down on the
page doesn't work, because if it endsup with 1 row or 3 rows, it still looks
crappy)
 
M

Maurice

Hi Tieske,

In order to see if we can help it's important to see if first we get the
same problem. Unfortunately for you but fortunately for me I can not repro
the behaviour you are seeing. I created a form with quit a lot of tabpages
and made a popup form out of it. I get the expected result.

So my advice would be to create another form in your db with no source and
place a tab control on there. Insert the same number of pages as in your
original form and set the formproperty to popup. See if you get the same
result as with your original form.
 
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
 

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