vba 调整大小时,此位置的控件或子表单控件太大

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3447618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 11:59:14  来源:igfitidea点击:

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

ms-accessvbaaccess-vba

提问by Sivakanesh

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.

我在 Access 2003 中有一个简单的表单。该表单有一个 List 控件和一个按钮。我想让列表随表单(仅垂直)调整大小,而按钮仍位于列表的右下角。我在表单的调整大小事件上使用以下代码。

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

运行时错误“2100”:此位置的控件或子窗体控件太大

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.

这个错误发生在我分配commandButton.Top的那一行。如果我删除此行,则列表高度会发生变化。我在表单中没有任何子表单。

Does anyone know why this is happening?

有谁知道为什么会这样?

Thanks

谢谢

回答by Croberts

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

回答by AndyAccess

Came by here (as many have) with the same problem and then realised my issue. Be mindful when resizing a control to a larger size with regard to the order of setting properties. I would recommend setting the TOP and LEFT positions before HEIGHT and WIDTH. Although my final sized control should have fitted OK once resized, I had originally tried setting the WIDTH first which attempted to enlarge the control exceeding the width of the form. My application threw the 2100 error at that point. I really hope this helps someone! Also, don't forget to set dimensions in TWIPS which is set as INCHESS x 1440 (or CM x 566.9291), ie: .Width = 10 * 566.9291 to set a control width to 10cm.

来到这里(很多人都有)遇到同样的问题,然后意识到我的问题。在将控件调整为更大的尺寸时,请注意设置属性的顺序。我建议在 HEIGHT 和 WIDTH 之前设置 TOP 和 LEFT 位置。虽然我最终调整大小的控件应该在调整大小后适合,但我最初尝试首先设置 WIDTH,试图将控件放大超过表单的宽度。我的应用程序在那时抛出了 2100 错误。我真的希望这对某人有所帮助!另外,不要忘记在 TWIPS 中设置尺寸,设置为 INCHESS x 1440(或 CM x 566.9291),即:.Width = 10 * 566.9291 将控件宽度设置为 10cm。