We have seen in the previous example that all our Forms can be organized in one place with the use of a ListBox and can Open the Form by Double_Clicking an item in the list. As a result, based on the value in the Type field of the control table, a Form opens directly or runs a macro to perform a sequence of operations to prepare the output before opening a Form with the processed data linked to the Form.

The objective of this method that we are going to try out here is same, but we will do it differently. It is better to know more than one method, which we can use in our various Projects, rather than using the same thing everywhere.

For this example we need to design a small form (not a listbox) and make it look like a listbox.

First, create a table with two fields with the following field Types and sizes:

Field Name

Type

Size

Seq

Number

Integer

Desc

Hyperlink

Save the table with the Name: DataFiles2. Open the Table to add few records into it. In MS-Access 2003 we have a problem entering Hyperlink SubAddress of Objects from within the Database. But we can use more than one trick to beat this problem. First you must know how the Hyperlink data is stored within the Hyperlink field. The data is stored in a Four segments format, separated by # symbol.

Display Text # External File’s Hyperlink Address # Internal Objects Hyperlink SubAddress # Control Tip Text

You can use the last segment to display a text when you point on the Hyperlink and that segment we will ignore here.

Right clicking on the Hyperlink Field displays the Hyperlink Shortcut Menu and pointing to it will display the Edit Hyperlink option, select it. This is the same menu you have opened from the Hyperlink SubAddress property of the command Button to Link a Macro in Closing Forms Example. But the Dialogue Control displayed here doesn’t have the Object in this Database option in the Link To: list. You cannot browse to the database object to link its name directly into the Hyperlink field. But, you can use this dialogue box to enter data into the field.

  1. Type a Descriptive Text in the Text to Display box on the top of the dialog control.
  2. Type a hash symbol (#) followed by the type of object name (like Form, Report etc.) you are linking followed by the name of the Object itself after giving a space between the type and the Name in the Address: box at the bottom.

Example-1:

  1. Text to Display: Edit Employees’ Data
  2. Address: #Form Employees

Click OK button. The ‘Edit Employees Data’ text only will be displayed in the Hyperlink field of the table. When you click on the field the Employees Form will open.

Example-2:

You can achieve the same result by typing a 3-segment Hyperlink value in the table Desc field directly:

Edit Employees’ Data##Form Employees

You need to insert two hash (#) symbols between the Text to Display & the Hyperlink SubAddress segments to open an object from within the Database. The Object Type, like Form, Report, Macro and Table must be specified immediately after the 2nd hash symbol followed by the Object name itself after giving a space between them.

If you need to open an external file like a Word-File you can type the full path of the File like C:\My Documents\mywordfile.doc immediately after the first hash symbol. In that case the third segment is not required, if entered, it will be ignored.

Approaching to Edit a Hyperlink field is a tricky business. When you point the arrow key the field is ready to click and open the link not to facilitate editing. So selecting the field for editing is like catching a snake without getting a snakebite. You can approach the task in two ways.

  1. Point on the field and move the arrow towards the intersection of the left side field (if there is one) the pointing hand will change into a 3D + sign. At that point click the field to select the Hyperlink Field.
  2. Another method is to right-click on the Hyperlink field which will highlight the field and open the shortcut menu. Click outside somewhere to remove the shortcut menu displayed.

After selecting the Hyperlink field you can edit the contents by using the Example-2 method explained above.

Enter few more records in the DataFiles2 Table to open the Objects of your choice by entering their Object Type and Name correctly in the Hyperlink SubAddress segment and close the Table.

Now we need to design a small form. Click the Table and select Form from the Insert Menu and select AutoForm: Tabular from the New Form Wizard and click Ok. A tabular form is created and opened in data view. Close the Form and save it with the Name: DataFiles2. Open the form in design view to change its properties to look like a listbox.

Unfinished Form image
  1. Click View menu and remove the check mark from the Form Header/Footer item. This action will display a warning message, click Yes to remove the Header & Footer Sections of the Form.
  2. Click on the left top corner of the form where the left-side and top scales meet, where a black square shows at the intersection, to select the Form rather than its controls.
  3. Press Alt+Enter keys or Click Properties from the View Menu to display the Form’s property sheet.
  4. Change the following Form Properties:
    • Allow Datasheet View : No
    • Allow Additions : No
    • Allow Deletions: No
    • Data Entry: No
    • Scroll Bars: Neither
    • Record Selectors: No
    • Navigation Buttons: No
    • Dividing Lines: No
    • Border Style: None
    • ControlBox: No
    • Min Max Buttons: None
    • Close Button: No
  5. Click on the Detail Section of the form and display the Property Sheet.
  6. Change the Back Color Property Value to 128 (will change to dark red color)
  7. Select the Seq Field control and change its width property to 0.2′
  8. Select Seq & Desc text boxes together, select Align – – > Left from the Format Menu, which will bring the controls close together.
  9. Select Shortest from the Format – – > Size Option to change both controls height to the same value.
  10. Now change the Properties (still both controls selected) of the controls to the following values:
    • Special Effect: Flat
    • Top: 0
    • Back Color: 128
    • Fore Color: 16777215
  11. Resize the form’s detail section close to the field sizes using the sizing handles at right and bottom edges of the form. Change both control’s border Color & Font weight:
    • Border Color: 128
    • Font Weight: Bold
  12. Select the Seq field alone and change the following properties to:
    • a. Enabled: No
    • b. Locked: Yes

The completed form in design view will look like the sample given below:

Form Design Completed

When opened in Form View, it will look like the sample below:

ListBox Preview

If you opened it in Form View select Close from the File Menu to close the Form. Now the remaining task is to insert this form into our Main Control Form and change few properties of the control to finish the final design and you are ready to go.

Close all other objects and ensure that the Database window is not minimized, if so restore it. Now, open the Control Form in design View. Select Tile Vertically from the Windows Menu. The Database Window and the Form will arrange side by side. Click on the Forms Tab (if it is not visible), click, drag and drop the DataFiles2 form on the Control Screen where you want the Menu Options to appear. Resize the control to the desired size. Change its child label Caption to: Data Files. Size the child label to the same size of the control and its Special Effect Property to Etched. Save the Form. The completed design on the Control Screen will look like the sample given below:

Click an Item in the Listbox, the Hyperlinks opens the Object (Form, Table, Macro etc.) attached to it.

When more links are added to the DataFiles2 Table they will appear in the list as well.

Click Next for Control Screen Design…

Download Demo Database