Microsoft KB Archive/166843

= ACC97: How to View Images from OLE Object Field in IDC/ASP Files =

Article ID: 166843

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q166843



SUMMARY
Advanced: Requires expert coding, interoperability, and multiuser skills.

When you export a table to HTML, IDC, or ASP format, Microsoft Access does not export OLE Object fields in the table.

This article demonstrates how you can display images from an OLE Object field in IDC or ASP files; this example does not work for HTML files. Note that the images from the OLE Object field must be a file type that is supported by your Web browser, such as *.bmp, *.jpg, or *.gif files.

NOTE: This method does not work with ASP forms; it only works with IDC or ASP files created from tables or queries.



MORE INFORMATION
In order to view images from your OLE Object field in an IDC or ASP file, you must store the image in a folder on your Web server's hard drive. Because of this limitation, the example in this article works best with images that are static or do not change very often -- pictures of products for sale or photographs of your employees, for example.

You can store images in two ways in an OLE Object field: embedded or linked. If your image objects are embedded in the table, you must create a copy of the image to store on your Web server; if your OLE Object images are linked to files on your hard drive, you can copy or move those files to your Web server. Note that with embedded images, if you change the OLE Object image, you must recopy it to your Web server in order to see your changes in the IDC or ASP file. If your images are linked, and you locate the linked files on your Web server, you can edit an image in your table and see your changes automatically the next time you open or refresh your IDC or ASP file; however, if you change a linked file that is not stored on your Web server, you must recopy the file to the server in order to see your changes.

The following example uses two different folders on your Web server. You store the graphics files in a folder where you have Read permission, and you store the IDC or ASP files in a folder where you have Execute permission. You can also modify the example to put all the files in a single folder for which you have both Read and Execute permissions.

Creating a File from a Stored Bitmap Image
The following steps show you how to create copies of employee photographs in the Northwind sample database. Then you copy those files to your Web server and modify the Employees table so that it will display an employee's photograph in your IDC or ASP file.

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.  Open the sample database Northwind.mdb, and open the Employees table in Datasheet view. Locate the employee record for Nancy Davolio, and double-click the bitmap image stored in the Photo field. This invokes Microsoft Paint (or whatever application you have associated with .bmp files) and opens Nancy's picture. In Microsoft Paint, click Save Copy As on the File menu. In the Save Copy As dialog box, type NancyD in the File Name box, and save the file to a folder on your Web server where you have Read permission, such as \Inetsrv\wwwroot or \Webshare\wwwroot. Quit Microsoft Paint, and return to Microsoft Access. Repeat steps 2 through 5 for Andrew Fuller, and save his bitmap picture as AndrewF in step 4. Switch the Employees table to Design view, and add a new field to display the bitmap image:

Table: Employees

Field Name: PhotoPath

Data Type: Text

</li> Save the Employees table, and then open it in Datasheet view.</li>  Type the following information in the PhotoPath field for Nancy Davolio and Andrew Fuller, and then close the Employees table: <pre class="fixed_text">  Record to Change     Enter in PhotoPath Field -  Nancy Davolio        <IMG SRC=\NancyD.bmp> Andrew Fuller       <IMG SRC=\AndrewF.bmp> NOTE: The path and file name you type after IMG SRC= in the PhotoPath field depends on the alias name for the folder where you store the bitmap files on your Web server. For example, if you store the bitmap files in the \wwwroot subfolder, which has an alias of /, enter \NancyD.bmp and \AndrewF.bmp in the PhotoPath field; if you store them in a different folder that has an alias of /Photos, enter \Photos\NancyD.bmp and \Photos\AndrewF.bmp in the PhotoPath field. </li></ol>

Exporting the Employees Table to IDC Format
<ol> Select the Employees table in the Database window.</li> On the File menu, click Save As/Export.</li> In the Save As dialog box, click "To an External File or Database," and then click OK.</li> In the "Save Table 'Employees' In" dialog box, select Microsoft IIS 1-2 (*.htx;*.idc) in the Save As type box. Type Employees.htx in the File Name box, and save the files to a folder on your Web server where you have Execute permission, such as the \Inetsrv\Scripts or \Webshare\Scripts folder. Click Export.</li> In the Data Source Name box of the HTX/IDC Output Options dialog box, type the name of a System DSN on your Web server that points to the Northwind sample database that you modified in the previous section. Click OK. This step creates two files: Employees.htx and Employees.idc.</li> Start Microsoft Internet Explorer, and type the Uniform Resource Locator (URL) to Employees.idc in the Address box. For example, if you saved the file in a folder on your Web server that has an alias name of /Scripts, type the following URL:

http://<Web Server Name>/Scripts/Employees.IDC

</li> Scroll down to the record for Nancy Davolio or Andrew Fuller and note that their photographs are displayed in the PhotoPath field of the table.</li></ol>

Exporting the Employees Table to ASP Format
NOTE: This section contains information about editing ASP files. It assumes that you are familiar with Active Server, Visual Basic Scripting, and editing HTML files. Microsoft Access Product Support professionals do not support modification of any HTML, HTX, IDC, or ASP files. <ol> Select the Employees table in the Database window.</li> On the File menu, click Save As/Export.</li> In the Save As Dialog box, click "To an External File or Database," and then click OK.</li> In the "Save Table 'Employees' In" dialog box, select Microsoft Active Server Pages (*.asp) in the Save As type box. Type Employees.asp in the File Name box, and save the files to a folder on your Web server where you have Execute permission, such as the \Inetsrv\Scripts or \Webshare\Scripts folder. Click Export.</li> In the Data Source Name box of the Microsoft Active Server Pages Output Options dialog, type the name of a System DSN on your Web server that points to the Northwind sample database that you modified for this example. In the Server URL box, type the URL for the folder on your Web server where you are saving this file. For example, if you save the file in the /Scripts folder on your Web server, type

http://<Web Server Name>/Scripts

and then click OK.</li> Using Notepad or another text editor, open the Employees.asp file to change the way the PhotoPath field is displayed. Look for the following line near the bottom of the file:

<TD BORDERCOLOR=#c0c0c0 ><FONT SIZE=2 FACE="Arial"

COLOR=#000000><%=Server.HTMLEncode(rs.Fields("PhotoPath").Value)%>

<BR></FONT></TD>

Modify the line so it looks as follows:

<TD BORDERCOLOR=#c0c0c0 ><FONT SIZE=2 FACE="Arial"

COLOR=#000000><%=rs.Fields("PhotoPath").Value%><BR></FONT ></TD>

</li> <li>Save and close the Employees.asp file.</li> <li>Start Microsoft Internet Explorer, and type the URL to Employees.asp in the Address box. For example, if you saved the file in a folder on your Web server that has an alias name of /Scripts, type the following URL:

http://<Web Server Name>/Scripts/Employees.asp

</li> <li>Scroll down to the record for Nancy Davolio or Andrew Fuller and note that their photographs are displayed in the PhotoPath field of the table.</li></ol>

<div class="references_section">