Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Wednesday, June 20, 2007

Control Screen Menu Design

Introduction

On the earlier topic of Control Screen Design, we explored how to display multiple menus in the same location on a form. Now, let’s take a look at a simple design using two menus—one for Data Files and the other for Reports—and how they can be displayed interchangeably at the same position on the screen.

To implement this, we need two tables:

  1. A table for the Data Files List.

  2. A separate table for the Reports List.

If you've already created a table for the Opening Access Forms example, you can simply make a copy of that table and rename it as ReportList for this purpose.


The Design Task

  1. Open a New Form in Design View.
  2. Click on the Tab Control Button on the Toolbox and draw a Tab Control on the new form's detail section as shown below:
  3. Click on the second page of the tab control where page2 is shown, and display the property sheet. Type Reports in the Caption Property.
  4. Click on Page 1 and Type Data Files in the Caption Property.
  5. Now we need to create a List Box. Before clicking on the Listbox button on the Toolbox, ensure that the Control Wizard (the button next to the arrow button) is selected in the Toolbox.
  6. When you point the arrow at the Tab control Page, after selecting the Listbox control, the Tab Control Page will highlight with a black background where you can position your Listbox. Draw a Listbox with the size of your choice.
  7. The List box Wizard starts up. Select the Data Files Table and select Seq & Desc Fields from the Table, and click Next. Select the Seq field for sorting in Ascending Order and click Finish.

    🔧 Reorganizing the List Box and Tab Control.

    1. Delete the Child Label of the List Box:

      • Click to select the label attached to the List Box (not the List Box itself).

      • Press Delete to remove it.

    2. Select the Tab Control:

      • Click outside the Tab Control.

      • Then drag your mouse over the Tab Control to select the entire object.

        • Tip: You can also click on the area to the right of the tab labels (e.g., to the right of "Page2") to select the control.

    3. Move the Tab Control:

      • With the Tab Control selected, drag it toward the right.

      • Leave enough space on the left side to place Command Buttons in the future.

      • This is important in case you plan to add a navigation menu or control panel later.

    4. Resize the List Box:

      • Click on the List Box to select it.

      • Adjust its width and height as needed to suit your layout preferences.

    We are concentrating only on the designing aspect of the controls, not running its options from the Listbox, which we have already discussed under the topic Opening Access Forms.

  8. Click on the Listbox and display its Property Sheet. Note down the following Property Values:
    • Left
    • Top
    • Width
    • Height

    Right-click on the Listbox on the first page and select copy from the shortcut menu.

  9. Click on the second Tab (Reports) to activate it, then hold the Shift key, right-click on the tab page, and choose Paste from the shortcut menu. This will copy the ListBox from the first page to the second. To change its Row Source, open the Property Sheet, click on the Row Source property, and then click the build button (...) next to it. In the Query Design window, add the ReportList table using the Show Table option. Replace the fields and table name  DataFiles with those from ReportList. Once done, remove the DataFiles table from the query design and close the window to save the changes.
  10. Display the Property Sheet of the Listbox on the 2nd Page, if it is not already visible, and change the values of the above properties (Top, Left, Width & Height) to the same value that we have noted down on the first page. Change the Fill Color and the Font Color to something different like blue background and white font color.
  11. Select the tab control using one of the methods explained under item 7 (2nd paragraph text in bold italics) above and display the property sheet. Change the following Property values:
    • Name = TabCtl0 (Zero at the end)
    • Back Style = Transparent
    • Multirow = No (default)
    • Style = Buttons

    View the Changes Done So Far.

  12. Save the form and open it in Form View. With the property changes applied earlier, the Tab Control now blends seamlessly into the form, making it almost unnoticeable. Click the buttons at the top to toggle between the Data Files and Reports menus. You'll see that both menus are displayed in the same space, switching smoothly based on your selection.
  13. If you don't like the Buttons at the top, create two Command Buttons on the left side, one below the other. Name the First one as cmdDF and change its Caption to Data Files. Name the second Button as cmdRpt and change its Caption to Reports.
  14. Select the first Command Button and display the Property Sheet. Add a line of code in the On Click Event Procedure:
Private Sub cmdDF_Click()
   Me.TabCtl0.Pages(0).SetFocus
End Sub

Write the following code in the On Click Event Procedure of the 2nd Command Button:

Private Sub cmdRpt_Click()
   Me.TabCtl0.Pages(1).SetFocus
End Sub

We need to make one more change on the Tab Control's Style Property Value = None.

To make the top Buttons disappear and then save the Form. Open it in the Form view and try out your design.  If you need more menus, you can add more Tab Control Pages

1 comment:

  1. [...] a Look at the following two Blog Posts: Control Screen Menu Design Drill-down Inquiry Screen __________________ http://www.msaccesstips.com (Learn MS-Access Tips [...]

    ReplyDelete

Comments subject to moderation before publishing.

Powered by Blogger.