469,301 Members | 2,272 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,301 developers. It's quick & easy.

How can I center Access 2007 switchboard opened to full screen?

26
I am creating a database in Access 2007 for multiple users, some with very limited experience with access. I am using a customized switchboard to make it more user-friendly.

I have the switchboard opening to full screen (covers all of the access window) and it is centered on my laptop but when I open the database on a different computer, different monitor size and resolution, it is not centered.

Is there anyway to have the switchboard centered, no matter the monitor size/resolution when opening to full screen?
Oct 6 '11 #1

✓ answered by ADezii

  1. The vast majority of the Code is encapsulated within 3 Class Modules, Import them into your DB from the Demo. The Class Modules are: ControlResize, FormResize, and SectionResize.
  2. In the Declarations Section of your Form's Code Module, place the following Declaration which will Declare a variable to represent a New Instance of the Class.
    Expand|Select|Wrap|Line Numbers
    1. Private mfr As FormResize
  3. In the Open() Event of the Form, Copy-N-paste the Code in the Demo's Form Open() Event to your Form:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Open(Cancel As Integer)
    2. 'Instantiate the Class to handle all resizing.
    3. Set mfr = New FormResize
    4.  
    5. 'Tell the new Object what form you want it to work with.
    6. Set mfr.Form = Me
    7.  
    8. 'For JAGster's Screen, Form Developement, Resolution 
    9. Call mfr.SetDesignCoords(1280, 772, 96, 96)
    10.  
    11. 'Set certain Properties
    12. With mfr
    13.   .ScaleForm = False
    14.   .ScaleColumns = True
    15.   .ScaleFonts = True
    16.   .ScaleControls = scYes
    17. End With
    18. End Sub

28 11438
ADezii
8,800 Expert 8TB
You can always make sure that a Form is Centered regardless of a User's Screen Resolution, but the Code is a little complex, and I do not believe that the Form can be Maximized. If you wish to see how this can be done, just let me know.
Oct 6 '11 #2
NeoPa
32,173 Expert Mod 16PB
Have a look at the AutoCentre property of the form.
Oct 6 '11 #3
JAGster
26
ADezil, I appreciate the offer on the code but I feel it necessary to have the switchboard opened to full screen for security and to avoid overwhelming users unfamiliar with Access.

NeoPa, The AutoCentre property is set to yes, but the form is not centered.

Thanks for the ideas. Any others will be greatly appreciated.

Regards, JAGster
Oct 6 '11 #4
ADezii
8,800 Expert 8TB
@JAGster: Kindly explain...
I feel it necessary to have the switchboard opened to full screen for security and to avoid overwhelming users unfamiliar with Access.
Oct 7 '11 #5
JAGster
26
ADezii,
I am concerned that inexperienced Access users will be confused/intimidated by the Access menus on the ribbon. I am also concerned about securing the database from tampering, inadvertent or otherwise.

I read a little bit of Rabbit's post on Securing a Database in Access and will look into the methods descrbed there for securing the database.

I am very interested in learning how to center forms, regardless of screen resolution. Thanks, JAGster
Oct 7 '11 #6
ADezii
8,800 Expert 8TB
How, exactly, are you Opening the switchboard to Full Screen?
Oct 7 '11 #7
JAGster
26
I got this from Jim Doherty's reply to an old post

min max buttons none
Borderstyle none
popup yes
navigation buttons no
Recordselectors no
scrollbars neither

In the on load event entered the code - DoCmd.Maximize
Oct 7 '11 #8
JAGster
26
The form is triggered to open from the Autoexec macro.
Oct 7 '11 #9
NeoPa
32,173 Expert Mod 16PB
So, if it's opening in Full Screen mode, how is it centred or not centred? Surely that is something that's relevant only in restored mode?
Oct 7 '11 #10
ADezii
8,800 Expert 8TB
@NeoPa:
Post #11 says it all from what I can see. It is not a matter of the Form itself being 'Centered' since this makes little sense in its 'Maximized' State. It appears to be a problem of centering the 'Controls' within this Form for various Screen Resolutions. A Command Button on a Maximized Form that is Centered on the Screen, will no longer be once the Resolution is changed. Technically the Controls on the Form need to be Scaled as well as Repositioned which can be done, but will be a little complex.

@JAGster: Is this correct?
Oct 7 '11 #11
NeoPa
32,173 Expert Mod 16PB
ADezii:
Post #11 says it all from what I can see.
Post #11 is the one you just posted ADezii :-S

I couldn't find any post that even seemed to indicate that, but if that's true, we have a much clearer question to answer. We'd need details of these controls of course and how they fit on the form generally. With that the situation is certainly handlable. I'm sure either of us could help with that.
Oct 7 '11 #12
ADezii
8,800 Expert 8TB
@NeoPa: Make that Post #8! (LOL)
Oct 7 '11 #13
JAGster
26
ADezii, You are correct, I misstated what I really needed to know how to do. Scaling and repositioning the controls for any resolution is what I need to do.

The controls are command buttons that are opening sub-switchboards. The sub-switchboard forms have command buttons to return to the main switchboard, close and exit the database, import files to populate tables, open split-forms with subforms, etc. I've attached a copy of the database with sensitive data removed.

I am in the process of changing the look and feel of the sub-switchboard forms and the other forms to be more like the main switchboard. My end goal is to either have all forms open full-screen with the controls scaled and repositioned or to have just the main switchboard and sub-switchboards open full screen with the controls scaled and repositioned and the other forms open centered on screen no matter the resolution (if they can open in front of the sub-switchboard form that is open full screen). I want the access window always hidden no matter what form(s) are open.
Attached Files
File Type: zip Inventory Part Validation - Sample.zip (74.7 KB, 210 views)
Oct 8 '11 #14
ADezii
8,800 Expert 8TB
Unfortunately, I can only use Access 2002 at this time. Kindly Convert a Copy of the DB (Forms only) to Access 2002, so that I can have a really good look at the Forms and Controls contained within.
Oct 8 '11 #15
NeoPa
32,173 Expert Mod 16PB
I just found out that maximised form windows keep the same values for height and width as when in restored view. I'm just seeing if I can find out how to determine the actual values for the form window. I know it will involve a Windows API call, I just don't know which yet ;-)
Oct 8 '11 #16
NeoPa
32,173 Expert Mod 16PB
It seems like you will need some code in your Form_Open() event I would suggest. It needs to determine the size of the form and its sections. The form object (Switchboard) has a Width property but only the sections have Height properties. This is worth remembering even though we won't be using these values due to their being unfit for purpose (See post #16). They remind us of the structure though. If you have multiple sections you will need to handle this in your logic. How you move things around within that, and what logic you use, is up to you (and we can't really comment as you haven't shared that with us), but you will almost certainly want to cycle through your controls to process each one. Here is a stub of code you can work with (I assume just a Detail section) :

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Declare Function GetWindowRect Lib "user32" _
  5.                              (ByVal hWnd As Long, recWnd As Rect) As Long
  6. Private Type Rect
  7.     Left As Long
  8.     Top As Long
  9.     Right As Long
  10.     Bottom As Long
  11. End Type
  12.  
  13. Private Sub Form_Open()
  14.     Dim lngWidth As Long, lngHeight As Long
  15.     Dim recForm As Rect
  16.     Dim ctl As Control
  17.  
  18.     Call GetWindowRect(Me.hWnd, recForm)
  19.     With recForm
  20.         lngWidth = .Right - .Left
  21.         lngHeight = .Bottom - .Top
  22.     End With
  23.     For Each ctl In Me.Detail.Controls
  24.         '...  Your logic
  25.     Next ctl
  26. End Sub
Oct 8 '11 #17
JAGster
26
NeoPa, All functioning controls (the Quarterly Audit button has no logic/function currently assigned to it) have an On Click event that calls a macro. All macros were included in the attached macro. Except for the macro triggered by the Exit "button" all other macros close the main switchboard and open another form. The macro for the Exit button saves and closes the database.

ADezii, I have attached a 2002 version of the sample database.
Attached Files
File Type: zip Inventory Part Validation - Sample 2002.zip (62.6 KB, 166 views)
Oct 10 '11 #18
Rabbit
12,516 Expert Mod 8TB
Use a subform as a container and then center the subform in the form's on load event.
Oct 10 '11 #19
JAGster
26
Rabbit, What settings/code is needed for the subform to be centered on the form no matter the screen resolution?

As a brief recap of what I'm trying to accomplish - I want to open a switchboard to full screen size, not maximized in the Access window, but full screen so none of the access toolbars, buttons, etc are visible. And have the controls on the switchboard centered no matter what computer/monitor or monitor resolution on which the database is running.
Oct 10 '11 #20
ADezii
8,800 Expert 8TB
@JAGster:
  1. To perfect Scaling, you must know specific information regarding the Screen Resolution that is active at the time you created the Form and its Controls. This info is used to create specific Ratios for Scaling all Objects. The info needed is:
    1. Horizontal Screen Resolution in Pixels
    2. Vertical Screen Resolution in Pixels
    3. Logical Dots/Inch X
    4. Logical Dots/Inch Y
  2. Download the Attachment that I have provided for you and Open frmScreenInfo. All the information that you need for proper Scaling is generated within. Copy the Call to the SetDesignCoords() Method generated at the bottom of the Screen, it will look something like this:
    Expand|Select|Wrap|Line Numbers
    1. Call frmResize.SetDesignCoords(1152, 830, 96, 96)
  3. Paste this Method Call and overwrite the comparable Line in the Load() Event of frmCentered (Line #9).
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Open(Cancel As Integer)
    2. 'Instantiate the Class to handle all resizing.
    3. Set mfr = New FormResize
    4.  
    5. 'Tell the new Object what form you want it to work with.
    6. Set mfr.Form = Me
    7.  
    8. 'For 1152 x 864 Screen Resolution at the Kimmel Center
    9. Call mfr.SetDesignCoords(1152, 830, 96, 96)
    10.  
    11. 'Set certain Properties
    12. With mfr
    13.   .ScaleForm = False
    14.   .ScaleColumns = True
    15.   .ScaleFonts = True
    16.   .ScaleControls = scYes
    17. End With
    18. End Sub
  4. Open Demo.mdb in any Screen Resolution. You should find that the Form covers the entire Screen and Scales all Controls/Fonts/Columns accordingly in any Screen Resolution, making it truly independent.
  5. If this actually works, I'll tell you what to do to incorporate this into your Database.
Attached Files
File Type: zip Centered.zip (330.1 KB, 299 views)
Oct 10 '11 #21
JAGster
26
ADezii,

After pasting the resolution information from the frmScreenInfo Call frmResize.SetDesignCoords(1280, 772, 96, 96)

I got compile error "variable not defined" and showing frmResize highlighted, when I tried to open the frmCentered.
Oct 10 '11 #22
ADezii
8,800 Expert 8TB
Try Call mfr.SetDesignCoords(1280, 772, 96, 96) first,

then

Paste mfr.SetDesignCoords(1280, 772, 96, 96) over the corresponding Line in the Open() Event of frmCentered in the Demo Database, not yours. Test the Demo at various Resolutions. If this works, then we can migrate to your DB. If you are still having trouble, I can modify the Demo at this end, then Upload the Revision to you for testing.
Oct 10 '11 #23
JAGster
26
It appears to be working. One questions regarding scaling. One monitor I am using is set at resolution 1280x772 (the display settings say 1280x800). The other one 1024x768. When I opened frmCenter on the second one the layout looks exactly the same as on the first one, but the picture of the globe is taller and narrower. Is this because of the scaling from the first resolution to the other?
Oct 10 '11 #24
ADezii
8,800 Expert 8TB
Is this because of the scaling from the first resolution to the other?
I would image so.

Don't forget that mfr.SetDesignCoords(1280, 772, 96, 96) must correspond to the Screen Data where the Form was created.

Test at various Resolutions, and try substituting the reported resolution instead of the actual ==> mfr.SetDesignCoords(1280, 800, 96, 96)
Oct 10 '11 #25
JAGster
26
I've tested on a number of different resolutions and it does work on all of them. So, I'm now ready migrate it to my database.
Oct 14 '11 #26
ADezii
8,800 Expert 8TB
  1. The vast majority of the Code is encapsulated within 3 Class Modules, Import them into your DB from the Demo. The Class Modules are: ControlResize, FormResize, and SectionResize.
  2. In the Declarations Section of your Form's Code Module, place the following Declaration which will Declare a variable to represent a New Instance of the Class.
    Expand|Select|Wrap|Line Numbers
    1. Private mfr As FormResize
  3. In the Open() Event of the Form, Copy-N-paste the Code in the Demo's Form Open() Event to your Form:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Open(Cancel As Integer)
    2. 'Instantiate the Class to handle all resizing.
    3. Set mfr = New FormResize
    4.  
    5. 'Tell the new Object what form you want it to work with.
    6. Set mfr.Form = Me
    7.  
    8. 'For JAGster's Screen, Form Developement, Resolution 
    9. Call mfr.SetDesignCoords(1280, 772, 96, 96)
    10.  
    11. 'Set certain Properties
    12. With mfr
    13.   .ScaleForm = False
    14.   .ScaleColumns = True
    15.   .ScaleFonts = True
    16.   .ScaleControls = scYes
    17. End With
    18. End Sub
Oct 14 '11 #27
JAGster
26
It works!

ADezii, Thanks for all the help! Very much appreciated.
Oct 14 '11 #28
ADezii
8,800 Expert 8TB
Glad it all worked out for you.
Oct 15 '11 #29

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

27 posts views Thread by Wayne | last post: by
9 posts views Thread by prakashwadhwani | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.