Solved How to set ms access main application window on restore size fixed (1 Viewer)

Ihk

Member
Local time
Tomorrow, 00:39
Joined
Apr 7, 2020
Messages
280
I want the ms access application window size to be fixed (height width etc) on restore command only.
On close I am using command
Code:
DoCmd.RunCommand acCmdAppRestore
But this restores to the size where user has already stretched the application to whatever extent. Meaning this restore size will be different on different PCs.
In this case, at very beginning at user login, user login form will open to that size (vary PC to PC on distribution). I want to be fixed at beginning /on app open.
Like we use it for forms for example
Me.InsideHeight = 2 * 3750
Me.InsideWidth = 5 * 2837
But this is for forms. I want for main app.
is there way to do that for app window on restore only (on close)?? thanks

Some one may ask why.... briefly.
1) login forms opens in small window, (popup = no), and on load: DoCmd.ShowToolbar "Ribbon", acToolbarNo
2) Dashboard opens with app maximized size.
3) on close app size is resotored.
Beautiy of this is it gives a software look, and is very flexible users can minimize, maximize, move the software to another 2nd screen, any popup forms can move to another screen.
 
Last edited:

Ihk

Member
Local time
Tomorrow, 00:39
Joined
Apr 7, 2020
Messages
280
@isladogs has code to hide the application window. That may work for you.
Yes I know that and have demo app from as well.
But that is borderless in all forms. Though it is really nice, may be i will use for other apps. At the moment to serve my purpose it not flexible as I mentioned above.
In my case, all forms opening from dashboard are of different sizes, sizeable, moveable to 2nd 3rd computer screens etc etc...

There must be function, to get main app window to specefic size, while closing or opening.
For example, I know from @arnelgp , he also has function which disables the close button of main access app window on title bar.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:39
Joined
Feb 19, 2002
Messages
43,233
I guess I'm confused. Are you talking about the Access window or individual forms. If you size and position the forms in edit mode, they will remember their state and open that way.

Are you by any chance sharing a FE? Every user should have his own personal copy of the FE. The FE should NEVER be shared. Only the BE is shared.
 

isladogs

MVP / VIP
Local time
Today, 23:39
Joined
Jan 14, 2017
Messages
18,209
I prefer using borderless forms when hiding the Access app window but you don’t have to do so. If you prefer, use thin or sizeable borders
 

Ihk

Member
Local time
Tomorrow, 00:39
Joined
Apr 7, 2020
Messages
280
I guess I'm confused. Are you talking about the Access window or individual forms. If you size and position the forms in edit mode, they will remember their state and open that way.

Are you by any chance sharing a FE? Every user should have his own personal copy of the FE. The FE should NEVER be shared. Only the BE is shared.
I am talking about..
Access Main App window ( the shell of app), not forms.
Yes talking about front end which is distributed to users as accde file.
 

Ihk

Member
Local time
Tomorrow, 00:39
Joined
Apr 7, 2020
Messages
280
I prefer using borderless forms when hiding the Access app window but you don’t have to do so. If you prefer, use thin or sizeable borders
Okay, if this is possible with the same, then i will try that tonight. Will see if it is moveable as well otherwise for each form have to make custome title bar with vba to make moveable.
 

isladogs

MVP / VIP
Local time
Today, 23:39
Joined
Jan 14, 2017
Messages
18,209
Any form with a title bar is movable without code. Borderless forms can only be moved using code though I have provided the code needed to do that
 

Ihk

Member
Local time
Tomorrow, 00:39
Joined
Apr 7, 2020
Messages
280
Any form with a title bar is movable without code. Borderless forms can only be moved using code though I have provided the code needed to do that
Yes exactly.
I will try that tonight. Question is, with same code your app, this will be possible. At the same time
1. App window hidden
2. Sizeable forms.
3. Maximze size
4. Restore size to level of my my login form size.., whatever the computer is after distribution.

Meaning 1st (login) always small , dashboard to maximize, then so on ...
I will try that.. and will update later..
 

isladogs

MVP / VIP
Local time
Today, 23:39
Joined
Jan 14, 2017
Messages
18,209
Yes to all of those. In fact much of that is demonstrated in my example app
 

Ihk

Member
Local time
Tomorrow, 00:39
Joined
Apr 7, 2020
Messages
280
Yes to all of those. In fact much of that is demonstrated in my example app
@isladogs
I tried from your app, because that app is full of features. I tried to extract the way it hides main app window. I got littel success, but still app window re.appears when we click on task bar. Even though I have called HideAppWindow Me on form load.
login form is hidden after login, so it also reappears by click on taskbar.
Sample db attached, if you have time. Thanks alot.
 

Attachments

  • Hide AppWindow.accdb
    744 KB · Views: 182

CJ_London

Super Moderator
Staff member
Local time
Today, 23:39
Joined
Feb 19, 2013
Messages
16,610
you can use the RECT property of the access window to determine the dimensions and location of the Access window when first opened. Store those values in a global variable and use the setwindowpos api to place back in it's original opened position and size as and when required

gettting the RECT of the access window

using setwindowpos (instead of restore)

In both cases it is assumed you have code run as soon as the app is opened to get the RECT - if the user opens access, resizes then opens the app then the resized parameters will be captured
 

isladogs

MVP / VIP
Local time
Today, 23:39
Joined
Jan 14, 2017
Messages
18,209
I've made several changes to both forms to fix the taskbar behaviour you described and improve usability

Form Login
- Removed the superfluous SW_SHOWMINIMIZED item - that was causing the app window to reappear when taskbar icon was clicked.​
- Clicking the X in the control box left you with an unusable database. I've removed it and added a Quit button​
If you prefer, add Application.Quit to the Form_Close event instead​
Whatever you do, always ensure you are in control of what happens when a form is closed especially if the app interface is hidden​
- Added code to close the login form when the dashboard is opened (rather than hide it)​
- Removed the shortcut menu to prevent right clicking into Design view - you'll see why if you try it on your version)​

Form Dashboard
- Added HideAppWindow Me to Form_Load​
- added Form_Close event to reopen Login form​
Also changed to overlapping windows display as you aren't using the tabs from tabbed documents
 

Attachments

  • Hide AppWindow-v2_CR.zip
    29.5 KB · Views: 201
Last edited:
  • Love
Reactions: Ihk

Ihk

Member
Local time
Tomorrow, 00:39
Joined
Apr 7, 2020
Messages
280
I've made several changes to both forms to fix the taskbar behaviour you described and improve usability

Form Login
- Removed the superfluous SW_SHOWMINIMIZED item - that was causing the app window to reappear when taskbar icon was clicked.​
- Clicking the X in the control box left you with an unusable database. I've removed it and added a Quit button​
If you prefer, add Application.Quit to the Form_Close event instead​
Whatever you do, always ensure you are in control of what happens when a form is closed especially if the app interface is hidden​
- Added code to close the login form when the dashboard is opened (rather than hide it)​
- Removed the shortcut menu to prevent right clicking into Design view - you'll see why if you try it on your version)​

Form Dashboard
- Added HideAppWindow Me to Form_Load​
- added Form_Close event to reopen Login form​
Also changed to overlapping windows display as you aren't using the tabs from tabbed documents
Thank you very much for your efforts. It is your greatness. App is working nicely. kind regards.
 

Ihk

Member
Local time
Tomorrow, 00:39
Joined
Apr 7, 2020
Messages
280
You're welcome
I came up with one question here, in real app having plus 15 forms. Some forms are pop up (yes) + Modal (yes) forms from the dashboard. Normally working fine. Only close button is yes.

1) Problem happens when I click on taskbar icon of app, then those popup forms get hidden and because modal is yes, so dashboard becomes unclick able, and dont find way to close those forms (because cant see them). So I have to close the whole app by task manager End task.
2) Pop up reports wont even show up.
What do you suggest in this case? Thank you again.

Just for demonstration, sample db attached.
Screen shots of one of the form and report properties are below.
1658085398338.png
1658085540155.png
 

Attachments

  • Hide AppWindow-v2_CR.accdb
    640 KB · Views: 149
Last edited:

isladogs

MVP / VIP
Local time
Today, 23:39
Joined
Jan 14, 2017
Messages
18,209
When the application interface is hidden, all forms & reports MUST be popups.
You also need to be careful about what is open and on top or you will get into a mess trying to deal with every possible sequence of objects being opened in turn

In order to prevent issues with which popup object is on top, I ALWAYS close an object when another object is opened.
It is reopened later if you need to return to that object,
For that reason, it is almost always unnecessary to have any objects opened as MODAL.

Ask yourself WHY you are making forms MODAL. Can it be avoided? I would say almost certainly yes

If you check my example app carefully, you will see those principles applied consistently.
So it ALWAYS works even those I have more complex arrangements than those you describe.

As for reports, the example app shows several different approaches including print preview, report view & report as subform.
Each method has advantages & disadvantages
 
  • Like
Reactions: Ihk

Ihk

Member
Local time
Tomorrow, 00:39
Joined
Apr 7, 2020
Messages
280
When the application interface is hidden, all forms & reports MUST be popups.
You also need to be careful about what is open and on top or you will get into a mess trying to deal with every possible sequence of objects being opened in turn

In order to prevent issues with which popup object is on top, I ALWAYS close an object when another object is opened.
It is reopened later if you need to return to that object,
For that reason, it is almost always unnecessary to have any objects opened as MODAL.

Ask yourself WHY you are making forms MODAL. Can it be avoided? I would say almost certainly yes

If you check my example app carefully, you will see those principles applied consistently.
So it ALWAYS works even those I have more complex arrangements than those you describe.

As for reports, the example app shows several different approaches including print preview, report view & report as subform.
Each method has advantages & disadvantages
Thank you very much for clarification. I learnt a lot. I can not stop appreciating you for your help. Kind regards.
 

Users who are viewing this thread

Top Bottom