Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Display Images in a Data Access Page


View products that this article applies to.

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).

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Keywords: KB263021, kbdapscript, kbdap, kbhowto

↑ Back to the top

Article Info
Article ID : 263021
Revision : 2
Created on : 7/13/2004
Published on : 7/13/2004
Exists online : False
Views : 274