Search code examples
vbams-access

The control or subform control is too large for this location on resize


I have a simple form in Access 2003. The form has a List control and a button. I wanted to make the list to resize with the form (only vertically) while the button remains at the bottom right of the List. I'm using the following code on the form's resize event.

list.Height = Me.InsideHeight - list.Top - 200
commandButton.Top = list.Height + list.Top + 50

This works fine as I resize the form, until the form height gets to a certain height. Then I get this error;

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

This error is occurring at the line where I'm assigning the commandButton.Top. If I remove this line then the list height changes fine. I don't have any subforms in the form.

Does anyone know why this is happening?

Thanks


Solution

  • I think it is because you need to resize the detail section of the form first.

    Try changing the code to

    Me.Section(0).Height = Me.InsideHeight 
    list.Height = Me.InsideHeight - list.Top - 200 
    commandButton.Top = list.Height + list.Top + 50