Full Version: Run-time Error '2100' In Treeview Form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
ruelralph
Gents,

I would like to seek your assistance for the code below which recently it gives an error "Run-time error '2100'", but previously is not, meaning i have been using this form and no error, just when i will add or edit something this error comes up.


= = = =
Private Sub Form_Resize()
On Error Resume Next
Const conBorderDistance As Integer = 100 'Distance of all controls to the form's boundaries
Const conTV_Width = 3000 'The width of the treeview (the subform will use the remaining space)
Const conTV_HeightDeviation As Integer = -5 'The treeview will be slightly higher than an access-control

Painting = False 'This will avoid the form flickernig while being resized

'Reset the controls (in case form is now smaller than before)
With tvSB
.Left = 0
.Top = 0
.Height = 0
.Width = 0
End With
With Switchboard_Subform
.Left = 0
.Top = 0
.Height = 0
.Width = 0
End With

'Adjust detail-section's size
Me.Section(acDetail).Height = Me.InsideHeight _
- Me.Section(acFooter).Height - Me.Section(acHeader).Height

'Reposition the controls
With tvSB
.Left = conBorderDistance
.Width = conTV_Width
.Top = conBorderDistance
.Height = Me.Section(acDetail).Height - conBorderDistance * 2
End With

With Switchboard_Subform
.Left = tvSB.Left + tvSB.Width + conBorderDistance
.Width = InsideWidth - tvSB.Width - conBorderDistance * 3
.Top = conBorderDistance
.Height = tvSB.Height + conTV_HeightDeviation
End With

Painting = True
End Sub

===


Appreciate your kind assistance.

Many thanks.
cheekybuddha
Hi,

What is the error description for "Run-time error '2100'"?

d
ruelralph
below is the complete error:

Run-time error '2100':
The control or subform control is too large for this location.

My concern is that the code or the form is running perfectly for the past few days(weeks) and i did not changed anything on the code. Then this error just pops-up.


Many thanks for the help.
ruelralph
by the way, just for info. the main form contains also the code for resize, see below:


the below procedure is in the Main Form, "On Resize", the earlier code is on the subform.

Private Sub Form_Resize()
On Error Resume Next
Const conBorderDistance As Integer = 100 'Distance of all controls to the form's boundaries
Const conTV_Width = 3000 'The width of the treeview (the subform will use the remaining space)
Const conTV_HeightDeviation As Integer = -5 'The treeview will be slightly higher than an access-control

Painting = False 'This will avoid the form flickernig while being resized

'Reset the controls (in case form is now smaller than before)
With tvSB
.Left = 0
.Top = 0
.Height = 0
.Width = 0
End With
With Switchboard_Subform
.Left = 0
.Top = 0
.Height = 0
.Width = 0
End With

'Adjust detail-section's size
Me.Section(acDetail).Height = Me.InsideHeight _
- Me.Section(acFooter).Height - Me.Section(acHeader).Height

'Reposition the controls
With tvSB
.Left = conBorderDistance
.Width = conTV_Width
.Top = conBorderDistance
.Height = Me.Section(acDetail).Height - conBorderDistance * 2
End With

With Switchboard_Subform
.Left = tvSB.Left + tvSB.Width + conBorderDistance
.Width = InsideWidth - tvSB.Width - conBorderDistance * 3
.Top = conBorderDistance
.Height = tvSB.Height + conTV_HeightDeviation
End With

Painting = True
End Sub

====

many thanks again.
cheekybuddha
When increasing the size of a control the form will automatically increase in size if it is too small (ie you make the control larger than the boundaries of the form).

However, if you make the form smaller than a control on the form you will receive the error you describe.

So the trick is to apply the resizing code to the controls before the form.

(I hope I've got all this the right way round!!)

I suggest putting:
CODE
'Adjust detail-section's size
Me.Section(acDetail).Height = Me.InsideHeight _
- Me.Section(acFooter).Height - Me.Section(acHeader).Height

at the end of the procedure.

Perhaps also test to see whether Detail's height is less than the .Top of the bottom-most control and adjust if necessary. i.e if your bottom-most control has .Top = 100 twips and you try and set the detail's height to 0 it will error even if the control has height = 0.

hth,

d
ruelralph
Hi D,

Many thanks for the response.

I have tried several numbers but its seems not working. I'm just wondering that i have been using the form for several weeks now then this error just occurred.

I'm sorry that i not really an expert in ms access, i have attached the mdb, i'm not sure if there's a bug in the program but sometimes when opening it there is No error, but modifying or adding something in the db, the error occurs and it does not fixed itseft even if you undo anything that have been done.

by the way the earlier code is for the Main Form. Below is the subform that requires to resize itseft.

Private Sub Form_Resize()
On Error Resume Next
Const conBorderDistance As Integer = 100 'Distance of all controls to the form's boundaries

'Reset (in case form is now smaller than before)
With imgLogo
.Left = 0
.Top = 0
End With
With lblHeader
.Left = 0
.Width = 0
.Top = 0
End With
With lblInfo
.Left = 0
.Width = 0
.Top = 0
End With

'Reposition the controls
With imgLogo 'upper right
.Left = InsideWidth - .Width - conBorderDistance
.Top = conBorderDistance
End With
With lblHeader 'centered both vertically and horizontally
.Left = conBorderDistance
.Width = InsideWidth - conBorderDistance * 2
.Top = (Section(acDetail).Height - .Height) / 2
End With
With lblInfo 'bottom / centered
.Left = lblHeader.Left
.Width = lblHeader.Width
.Top = Section(acDetail).Height - lblInfo.Height - conBorderDistance
End With

'Adjust detail-section's size
Me.Section(acDetail).Height = Me.InsideHeight _
- Me.Section(acFooter).Height - Me.Section(acHeader).Height
End Sub



Many thanks again for the assistance.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.