Form position on screen

Sess

Registered User.
Local time
Today, 02:40
Joined
Jan 4, 2010
Messages
74
I tried to search this but all the answers seemed to lead to people making a form fit different size screens and being centered, actually all I want to do is to have my forms open up in the top left corner of the screen.
Hopefully this is just a setting to either find the top left or something to stop it from being moved to the center of the screen I am creating this stuff on.
I am using Access 2003 and Win XPpro. When I make a form in Design View and save it and view it I have it at the top left of my screen. If I close the application and reopen it it goes to the middle of the window always. That would not be a bother except there are all sorts of different size screens that will use the apps including some of the old glass ones that are not even wide screen. On those half the form is squashed over so it fits the window it is annoying to say the least.
So I do not want to resize to fit each and every possible format of screen just poke the stuff up in the top left corner of the window.
 
Turn the form's Auto Center property off, or set it to no (whichever applies) and use the Move method on the Load event of the form.

Me.Move(left, top, width, height)
 
Have a look at the attached:
I have never run it in 2003 so tell me if you have any issues!

As you can see I havent really finished it....
Import the form into your db if it helps you, else have a look at the code it uses
 

Attachments

Thank you vbaInet. I went and turned AutoCenter to No and moved the form and saved it and it is where I want to place the form, even on the worst screen in the building.
For the Move coding I can get Me.Move (Left = 0) to work but Me.Move (Left = 0, Top = 0) does not it gives me a error message
Compile error: Expected: =

Thank you dcb I will try that after to see the code.
 
Thank you vbaInet. I went and turned AutoCenter to No and moved the form and saved it and it is where I want to place the form, even on the worst screen in the building.
For the Move coding I can get Me.Move (Left = 0) to work but Me.Move (Left = 0, Top = 0) does not it gives me a error message
Compile error: Expected: =

Thank you dcb I will try that after to see the code.

You should be using Me.Move 0,0,1000,10000
Have a look at movesize

The form I uploaded auto generates this for you
 
Oh well. I tried to open that zip and it gave me unrecognized format error and would not even open in access2003.

Have a look at the attached:
I have never run it in 2003 so tell me if you have any issues!

As you can see I havent really finished it....
Import the form into your db if it helps you, else have a look at the code it uses
 
THANK YOU!
I put Me.Move 0,0 into OnLoad event and YAY BINGO that is perfect perfect this will stop people from boogering up where the form is on the screen.

O the mdb does not open, the zip is fine.

You should be using Me.Move 0,0,1000,10000
Have a look at movesize
The form I uploaded auto generates this for you
 
Thank you vbaInet. I went and turned AutoCenter to No and moved the form and saved it and it is where I want to place the form, even on the worst screen in the building.
For the Move coding I can get Me.Move (Left = 0) to work but Me.Move (Left = 0, Top = 0) does not it gives me a error message
Compile error: Expected: =

Thank you dcb I will try that after to see the code.

I hope you're not writing just "top" and "left" inside the function's paramters? You can if you used ":=". Try this:
Code:
If Me.Moveable Then 
    Me.[B]Move[/B] Left:=0, Top:=0, Width:=400, Height:=300 
Else     
    MsgBox "The form cannot be moved." 
End If
Apparently, you must provide all the other paramters if you were going to set more than one property. All the dimensions are in twips. Remember to set the Moveable property of the form to Yes as well (found on Format tab).

To get the width and height of your form (in twips, which is what you need), just put this:
Code:
Msgbox "height: " & Me.Height & vbcrlf & "width: " & Me.Width
on the form's load event. Then use those values for the height and width parameters.
 
Thank you vbaInet
I will now be putting
Me.Move 0, 0
Me.Moveable = False
into the OnLoad event so that people can not booger around with the position of the forms. I am not at the point yet of the width and height being fixed. I am not going to try to put the thing with a message that "The form can not be moved" because that will put ideas into peoples heads and they will be requestion forms they can move around.

I hope you're not writing just "top" and "left" inside the function's paramters? You can if you used ":=". Try this:
Code:
If Me.Moveable Then 
    Me.[B]Move[/B] Left:=0, Top:=0, Width:=400, Height:=300 
Else     
    MsgBox "The form cannot be moved." 
End If
Apparently, you must provide all the other paramters if you were going to set more than one property. All the dimensions are in twips. Remember to set the Moveable property of the form to Yes as well (found on Format tab).

To get the width and height of your form (in twips, which is what you need), just put this:
Code:
Msgbox "height: " & Me.Height & vbcrlf & "width: " & Me.Width
on the form's load event. Then use those values for the height and width parameters.
 
Haha! Of course you don't want to do that. That was just fyi.
 
Thank you.
When I selected TestFrm1 it returned a runtime error 2465
Application-defined or object defined error
fFitToScreen = fCurrentForm.FitToScreen

appologies
Herewith
 
O okay so all the end users are sort of like that, hahaha, I just thought I had a difficult bunch here.
Ummm maybe I should sieze the opportunity to ask how to fix the width so they can not squash it to 1x1 pixel or stretch it so it would fit on their home 52" LCD television.

Haha! Of course you don't want to do that. That was just fyi.
 
The dcbFormSizer was what I was giving you
The silly test form has a whole bunch of 2007 controls in it - forgot to remove

I am just interested to see if it works on 2003 as I dont have that installed to test on - would be appreciated if you could test?
 
O okay so all the end users are sort of like that, hahaha, I just thought I had a difficult bunch here.
Ummm maybe I should sieze the opportunity to ask how to fix the width so they can not squash it to 1x1 pixel or stretch it so it would fit on their home 52" LCD television.

Why are you trying to stop this?

Use the resize event and check that the size is within your limits: however its all depends on screen res.....!
 
I would be happy to help you back.

I ran it again and when I selected dcbFormSizer_V3 as the Current Form it returned the same runtime error 2465
Application-defined or object defined error
fFitToScreen = fCurrentForm.FitToScreen

The dcbFormSizer was what I was giving you
The silly test form has a whole bunch of 2007 controls in it - forgot to remove

I am just interested to see if it works on 2003 as I dont have that installed to test on - would be appreciated if you could test?
 
Of Course.....
FitToScreen is not available in 2003!

Let me make some changes - Thanks
 
Should work in 2003 now: (I Hope)
I cant seem to see any other offending events.....:confused:
 

Attachments

Users who are viewing this thread

Back
Top Bottom