Learn how to a build a cloud-first strategyRegister Now


How do you control the way Access forms open?

Posted on 2011-04-21
Medium Priority
Last Modified: 2012-05-11
When the current database window is maximized within Access' main window, any form opens up maximized, whether by double-clicking its name in the forms pane or by using the DoCmd.OpenForm in a VBA macro.  When the current database window is not maximized within Access' main window, forms appear to open up the way they were last saved... I think.  Is there a way to have total control over this?
Question by:musgah
  • 2
LVL 75

Accepted Solution

DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 35442533
You can use these commands in the Form Load event of each Form:

Private Sub Form_Load()
    DoCmd.Maximize   ' one or the other of these two
    '  DoCmd.Restore
End Sub

LVL 26

Assisted Solution

Nick67 earned 1000 total points
ID: 35445061
Form Load, as mx said.

I have a modal form that, when I develop on dual monitors, had a habit of squashing itself skinny and flat invisible on single monitor machines.
I now place and size it on open

With DoCmd
    .SelectObject acForm, "frmJobID"
    .MoveSize 0, 0 'this puts the form in the upper left corner
End With
Me.Width = 6.5 * 1440 ' 6.5 inches x 1440 twips per inch
Me.InsideHeight = 2.125 * 1440
Me.InsideWidth = 6.25 * 1440
LVL 26

Assisted Solution

Nick67 earned 1000 total points
ID: 35445066
Replace "frmJobID"  with your form's name
Replace the decimals with your prefered size in inches

Assisted Solution

TT2 earned 500 total points
ID: 35445241
If you are using either Access 2007 or Access 2010 then you will need to make sure the following setting is made:

With the Database loaded, go to File|Options|Current Database and, under the Document Window Options Section,  select the "Overlapping Windows" Option Button" rather than "Tabbed Documnents" and don't forget to click the OK button after making the change.  

Essentially, if you have a non-maximised form (e.g. Main Menu or Switchboard)... and you want to open another form, that will be maximised, whilst leaving the original form open underneath, you can put the VBA code "DoCmd.Maximize" in the second form's Open Event (or Load Event,as DatabaseMX suggests).  

When you want to close-down the second form, you can place the VBA code "DoCmd .Restore" in the Close Event (or Load Event)... This ensures that the initial (Main Menu) form doesn't appear in Maximized state but, rather, exactly as it was when originally opened.

If the initial form is Maximized and the second form needs to appear, Non-Maximised, over the top of the initial form, then you can set the Auto Center and Auto Resize (Format Tab) Properties to Yes... and, if required, the Pop Up and Modal (Other Tab) Properties to Yes.

If the first form needs to be unseen whilst the second form is open, then the second form's Open Event can contain the VBA code "Forms![<FormName>].Visible = False" and the Close Event will contain the VBA code "Forms![<FormName>].Visible = True"

Placing the  code in the Open-Close or Load-Unload Events (I've never found that much difference) will ensure that the change in size works smoothly  - For reference the opening/closing sequence of events for a form is: Open>Load>Activate........Deactivate>Unload>Close,

Hope that's not too confusing... and that it helps.

Glen Ashton


Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question