MoveAndSizeWindow macro action
Applies to: Access 2013, Office 2013
If you have set your document window options to use overlapping windows instead of tabbed documents, you can use the MoveAndSizeWindow action to move or resize the active window. For information on how to set document window options, see the Remarks section.
Setting
The MoveAndSizeWindow action has the following arguments.
Action argument |
Description |
---|---|
Right |
The new horizontal position of the window's upper-left corner, measured from the left edge of its containing window. Enter the position in the Right box in the Action Arguments section of the Macro Builder pane. |
Down |
The new vertical position of the window's upper-left corner, measured from the top edge of its containing window. |
Width |
The window's new width. |
Height |
The window's new height. |
If you leave an argument blank, Microsoft Access uses the window's current setting.
You must enter a value for at least one argument.
Note
Each measurement is in inches or centimeters, depending on the regional settings in Windows Control Panel.
Remarks
To set up an application to use overlapping windows instead of tabbed documents, use the following procedure:
Click Options
Click Current Database.
In the Application Options section, under Document Window Options, click Overlapping Windows.
Click OK, and then close and reopen the database.
This action is similar to clicking Move or Size on the window's Control menu. With the menu commands, you use the keyboard's arrow keys to move or resize the window. With the MoveAndSizeWindow action, you enter the position and size measurements directly. You can also use the mouse to move and size windows.
You can use this action on any window, in any view.
Tip
- To move a window without resizing it, enter values for the Right and Down arguments but leave the Width and Height arguments blank.
- To resize a window without moving it, enter values for the Width and Height arguments but leave the Right and Down arguments blank.
To run the MoveAndSizeWindow action in a Visual Basic for Applications (VBA) module, use the MoveSize method of the DoCmd object.
Example
Synchronize forms by using a macro
The following macro opens a Product List form in the lower-right corner of the Suppliers form, displaying the current supplier's products. It shows the use of the Echo, MessageBox, GoToControl, StopMacro, OpenForm, and MoveAndSizeWindow actions. It also shows the use of a conditional expression with the MessageBox, GoToControl, and StopMacro actions. This macro should be attached to the Review Products button on the Suppliers form.
Condition |
Action |
Arguments: Setting |
Comment |
---|---|---|---|
Echo |
Echo On: No |
Stop screen updating while the macro is running. |
|
IsNull([Supplier ID]) |
MessageBox |
Message: Move to the supplier record whose products you want to see, then click the Review Products button again. Beep: YesType: NoneTitle: Select a Supplier |
If there is no current supplier on the Suppliers form, display a message. |
GoToControl |
Control Name: CompanyName |
Move focus to the CompanyName control. |
|
... |
StopMacro |
Stop the macro. |
|
OpenForm |
Form Name: Product List View: DatasheetFilter Name: Where Condition: [Supplier ID] = [Forms]![Suppliers]![SupplierID] Data Mode: Read OnlyWindow Mode: Normal |
Open the Product List form and show the current supplier's products. |
|
MoveAndSizeWindow |
Right: 0.7799" Down: 1.8" |
Position the Product List form in the lower right of the Suppliers form. |