Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Stretching Controls when resizing Form View

Sample image of an Employees Form Design is given below:

When you view this screen in a maximized Application Window, the view will be something like the following image:

The normal view of the Employees Form in maximized Application Window shows that an empty stretch of space to the right of data fields.  The Form Title Employees stays where it is placed in a Label control centralized over the data field controls.

Now, look at the following image taken after the Anchor Settings to the controls, which responds dynamically to move or stretch across the screen based on re-sizing of the screen:

Compare both images given above.  The second column of controls automatically moved to the right edge of the screen, when the screen is maximized.  Left side controls stretched to the right filling empty area giving more space for viewing or keying in information.  The heading Employees moved to the center of the screen.  The  Note field (memo field type) stretched down and across to display or edit more text into the field very easily.

Want to find out how to do it in MS-Access2007?  If you have a form with the design similar to the one shown on top of this page you may use that (this works with any form) to try this sample trick.

Let us design a Form with the Employees Table from the sample database Northwind.accdb.

  1. Import Employees Table from the Northwind.accdb sample database.
  2. Create a form with similar design shown on top of this page.  You can use the Form Wizard to create the form in Column format and rearrange the controls.
  3. Select all the controls of second column together and move it down, to get enough space for Fax Number and Address fields, which we are going to bring from the first column and place them on top of the second column.
  4. Select Fax Number and Address Fields, right-click on them to display the shortcut menu.
  5. Select Cut from the menu to remove both text boxes and their child-labels from the first column controls group.
  6. Right-Click somewhere on the Detail Section and select Paste to paste them back into the detail section.
  7. Move the pasted controls and place them on top of the second column of controls.
  8. Select and cut the Note Field and it’s child label from the second column and place them below the first column of controls.

So far, what we did was a normal form design by re-arranging controls as we normally do.  But, the Note field we have removed from the second column controls group and placed below the first column, as an independent control (not part of any controls group), to apply a different Anchoring action.

  1. Save the Form and open it in Form View to check how the current design look like.
  2. Change the Form in Design View.

    Let us start implementing the tricks one by one on the controls on the Form from top.  First, let us start with the header Label. We want this Form heading to get centralized within the available width of the form, when the Form View expands or shrinks.  If the text Employees in the header title label is not centralized within the current label width then select the label, select Center Ribbon button from Design Menu.  Now, we are ready to implement the magic settings on the controls.

    When the screen is maximized we want the heading label Stretch Across to the width of the screen so that the heading text Employees automatically move and center horizontally on the enlarged screen.  If the Form is resized manually to make it shrink or expand the label should respond accordingly. To make it happen do the following:

  3. Click on the heading label to select it.
  4. Select Arrange - - >Anchoring - - >Stretch Across Top.

    To test the effect of this setting you may open the Form in Normal View, maximize the form, check whether the form title ‘Employees’ moves across the screen to the center in the expanded screen or not.  You may try to manually resize the form window from right edge of the form, by displaying the sizing control on the mouse, by clicking and holding the left mouse button and dragging the right edge to left slowly and watch the heading label responds to the manual resizing action.  Or minimize the Navigation panel and display it again so that the form display window expands and shrinks quickly.  Now let us play few tricks with other set of controls on the Detail Section.

  5. Place the Form back into Design View.
  6. Highlight and select all the second column Text Boxes.
  7. Select Arrange - - >Anchoring - - >Top Right or right-click on the selected controls and select Anchoring - - > Top Right from the shortcut menu.
  8. Change the form into Form View and preview the effect of our setting. Change the form back into Design View again.
  9. Select the Text Boxes in the left column, except the Note field.
  10. Right-click on the controls and select Anchoring - - > Stretch Across Top.
  11. Select Notes field, right-click on the control and select Anchoring - - > Stretch Down and Across.

It is all done and you may save the form and open it in Normal View for testing by resizing the form view manually to view the action in slow motion.

Share:

No comments:

Post a Comment

Translate



PageRank
Your email address:

Delivered by FeedBurner

Search

Infolinks Text Ads


Blogs Directory

Popular Posts

Search This Blog

Blog Archive

Powered by Blogger.

Labels

Forms How Tos Functions MS-Access Security Reports msaccess forms Animations msaccess animation Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet Queries External Links msaccess reports msaccess tips Menus and Toolbars Accesstips MsaccessLinks Process Controls Art Work Downloads msaccess How Tos Graph Charts msaccessQuery List Boxes Command Buttons Emails and Alerts Query Combo Boxes Custom Wizards DOS Commands ms-access functions msaccess functions msaccess graphs msaccess reporttricks msaccessprocess security advanced Access Security Array Custom Functions Data Macros Menus Property Report Top Values VBA msaccess email msaccess menus progressmeter Access2007 Auto-Number Command Button Copy Form Join Microsoft Numbering System Records Security Split SubForm Table Utility Variables Workgroup database msaccess wizards Access2003 Accounting Year Action Animation Attachment Binary Numbers Bookmarks Budgeting Calculation ChDir Color Palette Conditional Formatting Controls Data Filtering Data Type Defining Pages Diagram Disk Dynamic Lookup Error Handler Excel Export Expression External Field Type Fields Filter Form Instances Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Methods Monitoring Object Reference Objects Octal Numbers Operating System Paste Primary-Key Product Rank Reading Recordset Rich Text Sequence SetFocus Summary Tab-Page Tables Time Difference Union Query User Users Water-Mark Word automatically commands function hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar tutorial updating upload vba code

Featured Post

Function Parameter Array Passing

Last week we have explored the usage of ByVal (By Value) and ByRef (By Reference),  in the Function Parameter, to pass the value from  a Va...

Labels

Blog Archive

Recent Posts