ACC2000: How to Display Images in a Data Access Page (263021)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q263021
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SUMMARY

Sometimes, you may not want to store images in a Microsoft Access table. You may not want to do this if you have many images, or if each of your image files is large. Image files can increase the size of an Access database quickly.

This article shows you an example of how to display images on a data access page in such a way that only the path and file name are stored in a Microsoft Access table.

MORE INFORMATION

  1. Open any Access 2000 database.
  2. Create the following table:
       Table: tblTest
       ----------------------------
       Field Name: ID
       Data Type: AutoNumber
       Indexed: Yes (No Duplicates)
    
       Field Name: Caption
       Data Type: Text
    
       Field Name: ImageURL
       Date Type: Text
       
       Table Properties: tblTest
       -------------------------
       PrimaryKey: ID
    					
  3. Put a few image files into a folder on your computer.
  4. Open the tblTest table in Datasheet view. Then, add the URL of each image file to a new record. The following example shows how the records might look:
       ID:   Caption:      ImageURL:
       1     Picture1      http://machinename/images/image1.jpg
       2     Picture2      http://machinename/images/image2.jpg
       3     Picture3      http://machinename/images/image3.bmp
    					
  5. Create a new data access page. Base it on the tblTest table. Add the ID and Caption fields to the new data access page.
  6. Add the field ImageURL to the data access page. Delete its associated label. Then, set its Visibility property to hidden.
  7. Add an Image control. In the Insert Image dialog box, click your first image, and then click OK.
  8. Set the properties of the Image control as follows:
        ID:  Image0
        Src: http://machinename/images/image1.jpg
    					
  9. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  10. Type or paste the following code:
    <SCRIPT event=Current(x) for=MSODSC language=vbscript>
    <!--
    	Image0.src=ImageURL.value	
    -->
    </SCRIPT>
    					
  11. Save the changes, and then close the Script Editor. Save the page, and then open it in a Web browser.

Modification Type:MinorLast Reviewed:7/13/2004
Keywords:kbDAP kbDAPScript kbhowto KB263021