Access Changes Formsize

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OldBirdman
    Contributor
    • Mar 2007
    • 675

    Access Changes Formsize

    I work in an Access window that approximates the size of my laptop screen. My current project has a form that vertically mostly fills the available space. If Access adds the Office Clipboard toolbar to the headings, the form no longer fits in the available space.

    Logic would dictate that vertical scrollbars be added. Not so! Access changes the size of my form, both height & width. It then centers the form within the space, and saves the settings.

    When I try to manually fix this, I remove the offending toolbar and close it, drag the form borders to resize, and save. I then switch to design view and save again.

    Opening the form in Form View may or may not have the form the correct size. Usually not. By repeated trial-and-error, I can eventually restore the form to its original size, approximately.

    So my questions are: 1)Can I prevent this from happening? and 2)How do I save the form's size?
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by OldBirdman
    I work in an Access window that approximates the size of my laptop screen. My current project has a form that vertically mostly fills the available space. If Access adds the Office Clipboard toolbar to the headings, the form no longer fits in the available space.

    Logic would dictate that vertical scrollbars be added. Not so! Access changes the size of my form, both height & width. It then centers the form within the space, and saves the settings.

    When I try to manually fix this, I remove the offending toolbar and close it, drag the form borders to resize, and save. I then switch to design view and save again.

    Opening the form in Form View may or may not have the form the correct size. Usually not. By repeated trial-and-error, I can eventually restore the form to its original size, approximately.

    So my questions are: 1)Can I prevent this from happening? and 2)How do I save the form's size?
    One popular method of saving a Form's dimensions is to write these values to the System Registry using the SaveSetting() Statement, then to later retrieve and apply them using the GetSetting() Function.

    Comment

    • OldBirdman
      Contributor
      • Mar 2007
      • 675

      #3
      I learned a lot about the Registry from that answer, which is a big mystery to me. But if I did as you suggest, I could just hard-code the form's dimensions into my code, and apply them at Form Open or Load or such.

      Within Form_Load I've tried
      Code:
         'DoCmd.MoveSize [right][, down][, width][, height]
          DoCmd.MoveSize 0.1 * 1440, 0.01 * 1440, 9.5 * 1440, 7 * 1440
      and it does not give consistant results. Sometimes the form is partially hidden below the bottom of the Access window, sometimes it is an inch below the top, with vertical scrollbars. The down value of 0.01 * 1440 should put it very close to the top. The width varies also with each try.

      Comment

      • OldBirdman
        Contributor
        • Mar 2007
        • 675

        #4
        Code:
        '   DoCmd.MoveSize      right,        down,      width,   height
            DoCmd.MoveSize 0.2 * 1440, 0.05 * 1440, 9.5 * 1440, 7 * 1440
        is what I want. Saving to the Registry is questionable, as I can't know when to do that, because I can't control the size. I have the MoveSize code in Form_Load, but it doesn't work.
        1) The 'frame' for my form is too small, not as I specify as height=7*1440. Access centers the form within the frame. Controls near the top are partially cut off. So are controls near bottom of form.
        2) The top is clearly further below the containing window than the left edge is from the left of the containing window.
        3) Even if I manually resize, Access may at any time change it again.
        Any suggestions?

        Comment

        • OldBirdman
          Contributor
          • Mar 2007
          • 675

          #5
          Results from further testing -
          Code:
          DoCmd.MoveSize 0.2 * 1440, 0.05 * 1440, 9.5 * 1440, 7 * 1440
          1) I was setting the size in the Form_Load Event, and the form in question does not have the focus because of other code in the same event. Therefore, a hidden form was having its size changed, but being hidden, I didn't notice.
          I fixed with Me.SetFocus before the MoveSize.
          2) Now when Access adds the Office Clipboard Toolbar, it adds vertical and horizontal scrollbars, but at least it doesn't change and save the form size.
          3) It is not possible to eliminate the vertical scrollbar after this happens, as the form is too close in size to the available space.

          Comment

          • FishVal
            Recognized Expert Specialist
            • Jun 2007
            • 2656

            #6
            Hello, OldBirdman.

            You may try to run code restoring your form parameters as soon as "Office Clipboard" toolbar pops. Code snippet below aggressively hides "Web" toolbar.

            Code:
            Option Compare Database
            
            ' declare variable with events
            Dim WithEvents objCmdBars As Office.CommandBars
            
            Private Sub Form_Close()
                ' cleanup
                Set objCmdBars = Nothing
            End Sub
            
            Private Sub Form_Load()
                ' set variable to the application commandbars collection
                Set objCmdBars = Application.CommandBars
            End Sub
            
            ' CommandBars.OnUpdate event fires whenever
            ' something happens to commandbar or commandbars collection
            Private Sub objCmdBars_OnUpdate()
                With Application.CommandBars("Web")
                    If .Visible Then .Visible = False
                End With
            End Sub
            Regards,
            Fish

            Comment

            Working...