• Macro command in form (2002)

    Author
    Topic
    #445035

    I have a field in the form that I want to show another form in “restore” size on top of the main form. I have created a macro using the macro helper that opens the secondary information form and restores it. I have put this in the On Click event. The only problem is that it also restores the main form, which I want to remain at maximum. Why is it doing this? How can I correct this?

    Also, how do I position this secondary form to appear where I want it?

    Viewing 0 reply threads
    Author
    Replies
    • #1077926

      If you specify Dialog as WindowMode in the OpenForm action, you don’t need to restore – the calling form will remain maximized and the called form will open restored.

      You can use the MoveSize action (or DoCmd.MoveSize in VBA) to specify the position of the window in the On Load or On Open event of the called form.

      • #1078003

        Thanks, Hans. As usual, you come to the rescue. I tried the DoCmd.MoveSize. I wanted it to move 3 inches to the right, 2 inches down and have the default width and height.
        It looked like this …

        Private Sub Form_Open(Cancel As Integer)
        DoCmd.MoveSize (3,2,,)
        End Sub

        To you it is probably obvious why it didn’t work. To a novice like me, it is like unlocking the secret to the universe.

        • #1078006

          The syntax is right, it just the units that are wrong. It does not use inches. Instead it uses twips.

          There are 1440 twips per inch, so the code probably did work, but the amount of movement was not detectable.

          Try DoCmd.MoveSize (4320,2880,,)

        • #1078019

          John Hutchison already supplied the solution.

          If you look up the MoveSize macro action in the Access help, you’ll see that it uses inches or centimeters, depending on your system setting.
          If you look up the MoveSize method of the DoCmd object in VBA, you’ll se that it uses twips, as explained by John Hutchison, where 1 inch = 1440 twips.

          • #1078108

            Thanks for the help. First time I have heard of a twip! Hey, maybe I can use that one in the classroom. “You little twip.” Funny that the Access help mentioned inches and centimetres, but not twips.

            • #1078118

              The help you refer to is for the macro action. That uses inches or centimeters, depending on your Windows system setting. The VBA method uses twips, and this is mentioned in the help for the VBA method.

    Viewing 0 reply threads
    Reply To: Macro command in form (2002)

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

    Your information: