Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button relocation problem

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
0
0
US
This might be more of an Access issue but since no one could help me on that forum I'm hoping to have better luck here.

I have a form with rows of fields that are initially 'visible=no'. As I fill in the rows I make them visible and at the same time increase the height of the form and move a button below the newly visible row. I do this with the following code:
Code:
    Me.Form.InsideHeight = Me.Form.InsideHeight + (0.25 * 1440)
    Me.MyButton.Top = Me.MyButton.Top + (0.25 * 1440)
This works fine until the value of 'Me.MyButton.Top' reaches 7860. When the above executes with that value I get the error, "The control or subform control is too large for this location." The value of 'Me.Form.InsideHeight' at this point is 8870 so there is plenty of room for the button which is 360 high.

Can someone help me with this? The message seems to be saying that the button is too large but that cannot be the case nor is the 'top' location too large for the form height. I'm stuck. TIA.
 
Hello,

InsideHeight is property to determine the HEIGHT (in twips) of the WINDOW containing a FORM.

Try this:

Me.Form.Section("Detail").Height = Me.Form.Section("Detail").Height + (0.25 * 1440)
Me.MyButton.Top = Me.MyButton.Top + (0.25 * 1440)
 
i'd try setting the button's position based on the detail's height, something like this:

me.mybutton.top = me.detail.height - 500

of course the 500 is just some arbitrary number. you would want to replace it with one that gives your button the amount of spacing you want it to have from the bottom, and that is greater than the height of the button and less than the height of the detail section in its smallest configuration

this helps to reduce the amount of calculation neccessary and helps to ensure a correltion between the detail section's height and the button's position. this is commonly called "anchoring".

- may seeds of dreams fall from my hands
and by yours be pressed into the ground
 
Thanks to all. I'll give it a try but probably won't get to it until the weekend.
 
One additional question before I try all this. Does the window as well as the detail have to be expanded or will the window automatically expand to accomodate the larger detail? TIA.
 
the window will expand as the detail section expands

- may seeds of dreams fall from my hands
and by yours be pressed into the ground
 
I finally got to try it and there is no joy in Mudville tonight. Here's what I have now:
Code:
Me.Form.Section("Detail").Height = Me.Form.Section("Detail").Height + (0.25 * 1440)
Me.MyButton.Top = Me.Form.Section("Detail").Height - 500
Still the same error at the same value for 'Me.MyButton.Top' (7860). The value of 'Me.Form.Section("Detail").Height' is 9052.

Their must be something else going on but I don't have a clue where to look.
 
As I was about to play with this more, I realized this is complete nonsense. I am SUBTRACTING a value. How can a smaller value be too large while a larger value is OK??????? I also do not see how 'Me.MyButton.Top' can wind up with exactly the same value as before when teh calculations are competlely different.
 
I think I found the problem. As I move the button down the form, its location is permanently changed!!! This problem is occurring on the very first attempt to relocate the button. I thought each time the form was loaded, it would restore the original location. I will now attempt to restore the location in the 'OnLoad' event. Why do not other parameter changes behave this way? My visible paramters all get restored each time? What am I missing?
 
Resetting the 'InsideHeight' in the 'OnLoad' event solved the problem. I now am using it successfully to reset my wnidow size. However, I now have done something that prevents me from accessing any of the parameters on my button. I'll address that as new thread.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top