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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Form width at runtime

Status
Not open for further replies.

scloud

Programmer
May 12, 2004
4
GB
Hi

I'm a complete newbie to this forum (this is my first thread), but not To Access.
I've returned to devloping Access apps after a few year break, last version I used was 97, now I'm using 2003 on XP home.
I'm trying to set a form width at runtime, simply using Me.width = <whatever>, where whatever is the value in twips.
Whatever i use, it's just completely ignoring it, no error, just not changing the size.
As a shot in the dark i tried me.Repaint after setting the width, to no avail.


I'd appreciate any help on this (I've searched help and the web for hours), I seem to remember this working in '97.

Regards

Ian
 
Just put the code in the forms OnLoad Event Procedure:

Code:
Me.Width = 72000

This will make your form 5" wide.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Hi Bob
Thanks for the reply.

I want to form to resize from a button on the form itself. So the onload event is no use.
I'm wanting to have the form expand when the user presses a "show me more" button on the form.
When they click it, the form should widen.


so this code needs to go in the button onclick event, which it is, but doesn't work.

Thanks again

Ian
 
Can't seem to make it work also. Will continue to experiment.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
I think this can be done by using either the SetWindowPos API or the MoveWindow API. But in either case, you're going to have to calculate and adjust for whatever MenuBars and/or ToolsBars that are also being displayed in the Access Client Window. Screen coordinate system and Access client coordindate systems have some conflicts that you must calculate around to get the right Top position of the window. But it is doable.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
And if that sounds overwhelming, then you can always use the .MoveSize method of the DoCmd object.

DoCmd.MoveSize , , Me.WindowWidth + 50

That will increase the window's width by 50 units.

DoCmd.MoveSize , , ,Me.WindowHeight - 50

That will decrease the window's height by 50 units.


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Is it a must that the form widen to show more info? What if you showed that extra info in the Form Footer and have the footer expand and collapse as needed. I have done this and it works great. Let me know if you are interested.
 
Glohamar: I was also thinking along these lines. I have used multiple pages with a page button up and down to jump through the pages as needed. The identfying info can be in a form header and the details group logically can be on different pages of the same form. No need to change the size of the form. Both should work well in this situation.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Thanks all. :)

I think I'll just go for the multiple page option, like you say.
Still curious as to why the me.width wont work tho.
ahhh, the joys of Access, it's starting to come back to me why i tooka a break. ;)


Regards

Ian
 
scloud: I had to search to find this thread as I had just read and tested some code in another thread that is releated. It seems that CajunCenturian has posted some code in thread: thread702-840818 that shrinks and expands the size of a form at runtime. He alluded to this code in his posting above but actually put it down in a posting in the mentioned thread. You might want to check it out as it is pretty dynamic in its application and I can see how it would look really great to the end user.

Good luck.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top