• stop the maximize of a window in macro

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » stop the maximize of a window in macro

    Author
    Topic
    #464703

    Hi everyone.

    I use a macro as the one shown below to open a particular form in my access database 2003. How can I keep it from opening in Maximized mode? In the form properties, I don’t see anything that actually helps. I place Autocenter on YES and Autoresize on NO, and yet it still maximizes when someone opens the form. I have a preset size I want it to be (manually resized it and saved it that way). But turn around and on someone elses computer it will open maximized… Is there something I can add to the following code to tell it to keep its shape when it opens? I have the action in the code set to acNormal

    Code:
    Private Sub btnOpenfrmNannetteEnterRecords_Click()
    'Attached to On Click event of cmdOpenfrmNannetteEnterRecords
    
    Dim strPassword
    
    strPasswd = InputBox("Enter Password", "Restricted Form")
    
    'Check to see if there is any entry made to input box, or if
    'cancel button is pressed.  If no entry made then exit sub.
    
        If strPasswd = "" Or strPasswd = Empty Then
            MsgBox "No Input Provided", vbInformation, "Required Data"
            Exit Sub
            End If
    
    'If correct password is entered open frmNannetteEnterRecords
    'If incorrect password is entered give message and exit sub
    
        If strPasswd = "Nannette123" Then
            DoCmd.OpenForm "frmNannetteEnterRecords", acNormal
        Else
            MsgBox "Sorry, you do not have access to this form", vbOKOnly, "Important Information"
        Exit Sub
        End If
    End Sub
    
    
    Viewing 6 reply threads
    Author
    Replies
    • #1190642

      The second argument acNormal has nothing to do with the window size – it specifies that the form opens in normal, i.e. form mode (as opposed to design mode, datasheet mode etc.)

      Is the form that contains btnOpenfrmNannetteEnterRecords maximized? If so, the other form will be opened maximized too.

      You could add a line

      DoCmd.Restore

      below the line with DoCmd.OpenForm.

    • #1190645

      Thank you Hans for the clarification on the code for acNormal

      The problem (even after entering your DoCmd.Restore is that when someone clicks on a macro button on the form (its of the proper size at the moment)…but when they click a button on the form for example to open another object like a datasheet, the datasheet opens in maximized mode, and when closed there is the form they originally used that maximized itself in the background instead of staying the size it was before the datasheet was open. It is like:

      1. The form is the perfect size
      2. Click a button on the form to open a datasheet in maximized mode
      3. Enter records.
      4. Close the datasheet
      5. There is the form used to enter the datasheet in the background but it grew (it maximized itself when the datasheet was open)

      Why can’t it remain the size it was before?

      • #1190646

        If you maximize a window within the Access application window, you maximize ALL windows, not just the one you maximize explicitly.

    • #1190647

      Darn…was hoping to find a way around it. Thank you Hans for your feedback.

      • #1190657

        Darn…was hoping to find a way around it. Thank you Hans for your feedback.

        There is another way to keep a form a fixed size, and that is to make it pop-up. Then even if the main Access window is maximized it will float over top of whatever else is open. Will that improve your situation?

        • #1191201

          There is another way to keep a form a fixed size, and that is to make it pop-up. Then even if the main Access window is maximized it will float over top of whatever else is open. Will that improve your situation?

          Wendell,

          Creating a pop up form works for keeping the size of the forms the same and stops the maximization of it when something is open. It keeps the size of the windows great, however, it does keep them in front of whatever you are opening, which I think will aggravate the person trying to open their reports etc…to view.

          On the “On Click” code event that I have at the beginning of this thread to open the example of “frmNannetteEnterRecords”, would there be a command I could use to make the pop up form go to the back of whatever they are opening?

          • #1191213

            You can’t send a popup form to the back of another window. But if you open popup form B from popup form A, it’ll open in front of popup form A.

            • #1191232

              You can’t send a popup form to the back of another window. But if you open popup form B from popup form A, it’ll open in front of popup form A.

              Understood. And that is working fine. It was just after opening form B from from A (after entering DB Password), form B (which there are several as there are several directors)…has macros that open that particular Directors reports, etc…and the popups do what popups do…stay in front of everything. So…

              I had thought that as the user clicks a button on Form B to open a report, there would be a possible way of minimizing or closing form B in the On Lost focus event (or some event) to close the popup as the report would be the desired object to now have the focus. (Yet it remains in the background behind Form A and Form B as they are popups doing what I wanted them to do, staying the size they are supposed to be…however removing themselves from view would have been nice too)…can’t have both. Now if Reports could be changed to popups, I’d be in the pink!

              solved

              they can be. thank you guys. sometimes we answer our own questions. that solved it. make the reports popups as well 🙂
              Anyway…
              Thank you for your help

    • #1190649

      You could add the line DoCmd.Restore to the On Close or On Deactivate event of the datasheet form.

      • #1190846

        You could add the line DoCmd.Restore to the On Close or On Deactivate event of the datasheet form.

        Hans, I will try both you and Wendells suggestions on Monday morning. Thanks you again. If either works will let you know.

    • #1190845

      Wendall,

      I will try this. Must wait until I can get back to the server on Monday, but definitly will give this a try. Thanks so much for the idea of the popup.

    • #1191214

      …however, it does keep them in front of whatever you are opening, which I think will aggravate the person trying to open their reports etc…to view.

      Unfortunately pop-up forms are intended to do exactly that. Their use is intended for situations where you need to briefly see a bit of data. User Interface design is a challenge in nearly all systems design projects. We take the idea that in general you only have one form open at a time, and you use a menuing function to control that. Getting many forms open at once just confuses the user. Also, we almost never use the datasheet view – if users need to see data in that format, we export it to Excel, or we create a form. For what it’s worth, we use the “Windows In the Taskbar” option in 2003 to let you click on reports and such, while in 2007 we use the tabbed documents option so the user can go to a specific window.

    • #1191230

      Wendell,

      Thank you. Yes, I am aware that users should not use the datasheet view. This database is a bit different…not the norm. That is why I am restructuring it…and the datasheets will appear in Add-Only mode when through. If they want to view anything else they must open the report.

      Appreciate all the help on this. Will work it out. Plus am rebuilding it on a 2007 Access loaded computer and have to make it complient with 2003 Access which everyone else has. What looks good in design on 2007 doesn’t always appear as well in 2003.

      • #1191241

        … Plus am rebuilding it on a 2007 Access loaded computer and have to make it complient with 2003 Access which everyone else has. What looks good in design on 2007 doesn’t always appear as well in 2003.

        That’s an understatement – the general advice is to always do development on the older version of Access. Otherwise when you take it to an older version you may end up with missing references and things that work well in the new version, but don’t in the older.

        Another option with popup forms is to hide the originating one (set the Visible property to False) when you open a new one, and then unhide it when the newer form is closed. That strategy works well until you have an issue with a form crashing or something. Then you end up with a hidden form you don’t know you have.

    Viewing 6 reply threads
    Reply To: stop the maximize of a window in macro

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: