Export (0) Print
Expand All
4 out of 6 rated this helpful - Rate this topic

Using Single Images Across Multiple Forms and Reports in Access 2010 Applications

Office 2010

Office Visual How To

Summary:  Learn how to use the image gallery in Microsoft Access 2010 to save space and replace images across multiple forms and reports.

Applies to:  Microsoft Access 2010

Published:  December 2010

Provided by:  Ken Getz, MCW Technologies, LLC

Overview

This article describes how to use the new shared image gallery in Access 2010. The shared image gallery enables you save space in the database by sharing images across multiple forms and reports. In addition, the gallery has a simplified interface. By using this interface, you can replace an image across a project.

Code It

Many database developers use shared images: logos, footers, headers, and so on. Often, a developer uses these images on each form or report in an application. Prior to Access 2010, Access created a separate instance of an image every time that you used an image. (The exception was if you manually wrote code to insert a single image at run time). In Access 2010, you can use the new image gallery, which enables you to share images across multiple forms and reports.

Creating the Sample Database

The first step is to create a sample Access database. You will use this database to experiment with the new image gallery.

To create the sample database

  1. Start Access 2010.

  2. In Access, click File and then New.

  3. In the list of available templates, under Office.com templates, select Samples.

  4. From the list of sample databases, select Northwind 2007.

  5. Select an appropriate path, and then click the Download button to download and install a clean copy of the sample database.

  6. If asked, click the Enable Content button in the Message Bar to enable the VBA code in the sample database.

  7. Accept the default logon ID in the Login Dialog form, and then click Login.

    At this point, you should have downloaded and installed a fresh copy of the Northwind 2007 sample database. In addition, Access 2010 will also have loaded the database.

  8. Close the default Home form.

Adding and Inserting an Image on a Form

Once you have downloaded and installed the sample database, you can add and insert the image on a form.

To insert an image using the image gallery

  1. Open the Customer Details form in Design view.

  2. In the ribbon, in the Design tab, in the Controls group, select the Insert Image drop-down menu and select Browse.

    Figure 1. Insert an image

    Insert Image
  3. In the Insert Picture dialog box, browse to and select an image to insert onto the current form.

  4. Click Open when you are finished.

    This action inserts the image onto the form, and also inserts the image into the image gallery.

  5. Select the Browse menu item again, and confirm that the image that you added now appears as part of the gallery.

    Figure 2. The image now appears in the gallery

    Image in the gallery
  6. On the form, select the image, and investigate the properties of the image.

    noteNote:

    By default, the Picture Type property is set to Shared. This indicates that the image comes from the gallery. Also, the Picture property contains the name of the image that you inserted.

    Figure 3. Image properties for the newly inserted image

    Image properties for the newly inserted image

Reusing the Image on a Report

Now that you have added an image to the gallery, you can reuse the image on any form and report.

To reuse the image on a report

  1. Open the Customer Phone Book report in Design view.

  2. In the ribbon, click the Insert Image drop-down menu, and select the image that you added previously.

  3. Click in the header of the report, and notice that this action inserts the image.

  4. Verify that the properties of the image match those that you saw when you work with the form.

Exploring the Gallery Storage

Access stores the images in a hidden system table name MSysResources, which you can easily locate.

To view the hidden system table

  1. Right-click the top of the Navigation Bar, and select Navigation Options from the shortcut menu.

  2. In the Navigation Options dialog box, select the Show Hidden Objects and Show System Objects check boxes.

    Figure 4. Turn on the display of hidden and system objects

    Show Hidden and Show System Objects display option
  3. Click OK when you have finished.

    You should now see the MSysResources table included in the list of existing tables.

  4. In the Navigation Bar, double-click the MSysResources table, displaying information such as that shown in Figure 5.

    As you can see, Access stores the image itself as an attachment, together with the file name extension, name, and type.

    Figure 5. Investigate the contents of the MSysResources table

    Contents of the MyResources table

Replacing the Image

Each instance of an image from the gallery that you display on a form or report actually contains a reference to the shared image. Therefore, you can easily replace an image across all uses, without having to visit each form or report.

To replace an image across all uses

  1. Save and close the forms and reports that you have previously modified.

  2. Re-open the Customers Detail form in Design view.

  3. In the Design tab, in the Controls group, click the Insert Image drop-down menu, right-click the image that you previously inserted, and then select Update from the shortcut menu.

    Figure 6. Update the existing image

    Update the existing image
  4. In the Insert Picture dialog box, select a different image, and then click Open to replace the existing image.

    noteNote:

    This action immediately replaces the image on the current form.

  5. Close the form, and open the Customer Phone Book report in Design view.

    You will see that changing the image in the gallery also changes the image in the report. This verifies that updating the image in the gallery updates the image for all uses.

Renaming the Image

Access retrieves an image from the gallery by using the image name as a keyword. As such, each shared image instance includes the name of the original image in the properties of the image container. Therefore, if you change the name of the picture in the galley, you must also manually update the name of each instance of the image in your application.

To rename the image

  1. With the Customer Phone Book report open in Design view, click the Insert Image drop-down menu, right-click the image that you added in the gallery and select Rename on the shortcut menu.

  2. Give the image a new name, and then click OK.

    noteNote:

    Notice that everything appears fine currently.

  3. Close the report, and then re-open the report in Design view.

    ImportantImportant:

    The report cannot display the image, because the report is looking for an image with the old name.

  4. Click on the image, and in the Properties window, fix up the Picture property by selecting the name that you assigned to the shared image.

Read It

Access 2010 stores the image gallery in the database itself. Therefore, you do not have to have any additional software to use the gallery. Because you store only a single copy of each image, you can significantly reduce the size of the database application. In addition, you can replace the image in the gallery in order to replace all instances of the image. This change will propagate to each form or report on which the image appears. You can therefore maintain your application much more easily by using this tool.

Be aware that Access includes a Logo button in the Header/Footer group of the Design tab for forms and reports. The Logo button inserts a selected image in the upper-left corner of the current form or report. For client forms and reports, Access stores the image directly on the form. For web forms and reports, Access stores the image in the gallery, and then places a reference to the image on the form or report.

ImportantImportant:

Be aware that in using the Logo button for client applications, the button places a single copy of the image that you select on each form and report. You can also use the image gallery to create a background image for a form or report. However, this feature works only for client forms and reports.

See It

Watch the video

Watch video

Length: 00:20:29

Explore It

About the Author
Ken Getz is a senior consultant with MCW Technologies. He is coauthor of ASP.NET Developers Jumpstart (Addison-Wesley, 2002), Access Developer's Handbook (Sybex, 2001), and VBA Developer's Handbook, 2nd Edition (Sybex, 2001).

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.