Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    St. Marys, Ontario, Canada
    Posts
    270
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro command in form (2002)

    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?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro command in form (2002)

    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.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    St. Marys, Ontario, Canada
    Posts
    270
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro command in form (2002)

    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.

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Macro command in form (2002)

    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,,)
    Regards
    John



  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro command in form (2002)

    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.

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    St. Marys, Ontario, Canada
    Posts
    270
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro command in form (2002)

    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.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro command in form (2002)

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •