How to resize form from code?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dustin Wilson

    How to resize form from code?

    I would like to resize the height of a form through a piece of code. I
    tried the following piece of code but got an error saying it was a read only
    property and can't be set. Is there a was to resize the form at runtime?
    Or is there a way to execute the command "Size to Fit Form" from the menu.

    'Start of Code
    Me.WindowHeight = fInchesToTwips( 2)
    'End of Code

    Thanks
    Dustin Wilson


  • Jim Allensworth

    #2
    Re: How to resize form from code?

    On Mon, 9 Feb 2004 09:40:51 -0600, "Dustin Wilson"
    <dwilson@REMOVE .kgsgroup.com> wrote:
    [color=blue]
    >I would like to resize the height of a form through a piece of code. I
    >tried the following piece of code but got an error saying it was a read only
    >property and can't be set. Is there a was to resize the form at runtime?
    >Or is there a way to execute the command "Size to Fit Form" from the menu.
    >
    >'Start of Code
    >Me.WindowHeigh t = fInchesToTwips( 2)
    >'End of Code
    >
    >Thanks
    >Dustin Wilson
    >
    >[/color]

    You can use DoCmd.MoveSize for this purpose.

    - Jim

    Comment

    • Lyle Fairfield

      #3
      Re: How to resize form from code?

      "Dustin Wilson" <dwilson@REMOVE .kgsgroup.com> wrote in
      news:ITNVb.2578 $N76.5391@news1 .mts.net:
      [color=blue]
      > runtime? Or is there a way to execute the command "Size to Fit Form"
      > from the menu.[/color]

      Private Sub Form_Load()
      With DoCmd
      .Restore
      .RunCommand acCmdSizeToFitF orm
      End With
      End Sub

      --
      Lyle
      (for e-mail refer to http://ffdba.com/contacts.htm)

      Comment

      • Dustin Wilson

        #4
        Re: How to resize form from code?

        Lyle

        Works perfectly. Exactly what I wanted. :)

        Thanks
        Dustin

        "Lyle Fairfield" <MissingAddress @Invalid.Com> wrote in message
        news:Xns948A765 DB5292FFDBA@130 .133.1.17...[color=blue]
        > "Dustin Wilson" <dwilson@REMOVE .kgsgroup.com> wrote in
        > news:ITNVb.2578 $N76.5391@news1 .mts.net:
        >[color=green]
        > > runtime? Or is there a way to execute the command "Size to Fit Form"
        > > from the menu.[/color]
        >
        > Private Sub Form_Load()
        > With DoCmd
        > .Restore
        > .RunCommand acCmdSizeToFitF orm
        > End With
        > End Sub
        >
        > --
        > Lyle
        > (for e-mail refer to http://ffdba.com/contacts.htm)[/color]


        Comment

        • Brendan Reynolds

          #5
          Re: How to resize form from code?

          "Dustin Wilson" <dwilson@REMOVE .kgsgroup.com> wrote in message news:<ITNVb.257 8$N76.5391@news 1.mts.net>...[color=blue]
          > I would like to resize the height of a form through a piece of code. I
          > tried the following piece of code but got an error saying it was a read only
          > property and can't be set. Is there a was to resize the form at runtime?
          > Or is there a way to execute the command "Size to Fit Form" from the menu.
          >
          > 'Start of Code
          > Me.WindowHeight = fInchesToTwips( 2)
          > 'End of Code
          >
          > Thanks
          > Dustin Wilson[/color]

          To execute the Size to Fit Form command programatically ...

          DoCmd.RunComman d acCmdSizeToFitF orm

          --
          Brendan Reynolds

          Comment

          • James Neumann

            #6
            Re: How to resize form from code?

            Justin,

            Try DoCmd.MoveSize, which will allow you to control the position of
            the current window. if you are executing code in a the Form_Load
            event, it should work OK. I haven't tried it on a subform, so I am not
            sure how that would work.

            If you are distributing your application, check out some of the
            discussions on sizing as it relates to screen resolution. They may be
            helpful, if that is what you are doing.

            James Neumann


            "Dustin Wilson" <dwilson@REMOVE .kgsgroup.com> wrote in message news:<ITNVb.257 8$N76.5391@news 1.mts.net>...[color=blue]
            > I would like to resize the height of a form through a piece of code. I
            > tried the following piece of code but got an error saying it was a read only
            > property and can't be set. Is there a was to resize the form at runtime?
            > Or is there a way to execute the command "Size to Fit Form" from the menu.
            >
            > 'Start of Code
            > Me.WindowHeight = fInchesToTwips( 2)
            > 'End of Code
            >
            > Thanks
            > Dustin Wilson[/color]

            Comment

            Working...