How to Maximize One Form And Not Others?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bullfrog83
    New Member
    • Apr 2010
    • 124

    How to Maximize One Form And Not Others?

    Upon opening my application I want my form f_Main to open maximized. I know that can simply be done by DoCmd.Maximize. However, as we all know, maximizing one form causes the rest to be maximized, which I don't want. In fact, the only form I want maximized at all times is f_Main. If I put DoCmd.Restore in a child window, it restores that window but it also restores the f_Main form, which I don't want.

    I understand that if I make all other child windows Pop Ups that'll work but I can't do that because, for some very strange reason, if you set a form to be Pop Up you can't delete any records from that form. Instead, what you end up deleting is a record on the parent window (and thus the parent record instead of a child record). Therefore, setting the Pop Up property = True will not work for me. With all this in mind is there a way for me to accomplish what I want?
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    In answer to your question, not that I am aware of.

    That is interresting about the popup/delete problem. I have never tried myself so I cannot comment on the accuracy of that statement.
    If indeed it is true, then setting the forms popup property can still work for you if you take control of the database operations with VBA instead. I know that requires more work from you but when you reallywant an effect that cannot be achieved through standard functionality, that is what you have to do.


    Unless there is a way that I do not know of.
    As far as access is concerned, everything is maximized or everything is not maximized.
    You could programmaticall y set the size of each form I suppose but then you need to find out the resolution each users monitor is set to.

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Setting a form to Popup or Popup/Modal does not, in and of itself, prevent records from being deleted! You have to have something else going on here that is doing this.

      Linq ;0)>

      Comment

      • bullfrog83
        New Member
        • Apr 2010
        • 124

        #4
        If that's true, then I wish I knew what the problem is! If I set it to Modal only then I'm alright. But if I set the PopUp property = True then I have the problem. There's another post (albeit old) on bytes where someone else encountered the same problem and had to create a delete button next to each record to solve it. I think that's superfluous. The thread is titled "Delete record on popup-subform impossible?"

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32634

          #5
          You could use the following code, but this makes no allowance for the stuff that isn't required around the edges when a form is maximised. I expect you can sort that out with a little playing around.
          Code:
              Dim lngWH As Long, lngWL As Long, lngWT As Long, lngWW As Long
          
              With Me
                  DoCmd.Maximize
                  lngWT = .WindowTop
                  lngWL = .WindowLeft
                  lngWH = .WindowHeight
                  lngWW = .WindowWidth
                  DoCmd.Restore
                  Call .Move(lngWL, lngWT, lngWW, lngWH)
              End With

          Comment

          • reginaldmerritt
            New Member
            • Nov 2006
            • 201

            #6
            That is a really nifty bit of code NeoPa.

            Any way of making it a public sub routine?

            tried using the following but came up with an error
            Can't find the form " refered

            Code:
            Public Sub FullScreen(ByVal strCurrentForm As String)
            Dim lngWH As Long, lngWL As Long, lngWT As Long, lngWW As Long
            With Forms(strCurrentForm)
                DoCmd.Maximize
                lngWT = .WindowTop
                lngWL = .WindowLeft
                lngWH = .WindowHeight
                lngWW = .WindowWidth
                DoCmd.Restore
                Call .Move(lngWL, lngWT, lngWW, lngWH)
            End With
            End Sub
            I called the sub using:
            Code:
            Private Sub Form_Load()
            FullScreen (FRMStaffList)
            End Sub
            Am I way of track here?

            Comment

            • MikeTheBike
              Recognized Expert Contributor
              • Jun 2007
              • 640

              #7
              Hi

              As you say pretty nifty code from NeoPa.

              I would suggest your load event should be
              Code:
              Private Sub Form_Load()
                  FullScreen Me.Name
              End Sub
              ??

              MTB

              Comment

              • reginaldmerritt
                New Member
                • Nov 2006
                • 201

                #8
                Thanks MTB. Great shout, works perfectly. ;)

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32634

                  #9
                  Sorry guys. been away for a week, but it seems Mike had you covered anyway. In that context that's exactly the way to call the procedure.

                  In response to your earlier question about making it more publicly accessible, that would require defining the procedure code (that you pretty well have perfect) in a standard module as opposed to within the module of a form (I'm just guessing this is what you have done from the question).

                  The only other point I would make is that you have the option of defining the passed parameter as a Form object instead of a string. That way you would pass the form itself, rather than the name. This may or may not suit your needs better (depending on other potential usages), but would mean you could simplify the With line, as well as the call to the procedure.

                  Comment

                  Working...