Microsoft KB Archive/139624

= How to print pictures in a report by using an embedded path =

Article ID: 139624

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b for Macintosh
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q139624



SUMMARY
There may be times when you don't want to embed pictures in general fields in a table. This article shows by example how to store the location of the picture file in a field in a table. The field holds the absolute path name that points to where the picture file can be found.

The technique in this article is especially useful for situations where your pictures are updated on a regular basis but continue to use the same file name. By using this technique, you can avoid having to update embedded pictures in a table. As a result, your tables are physically smaller, you always have the most current picture available to your application, and you continue to achieve the same functionality as you would with an embedded picture.

Although using an embedded path reference in place of an absolute file reference is not documented, you can achieve this functionality by using the Report Writer as documented in this article.



MORE INFORMATION
Using the Visual FoxPro Report Writer, you can place general fields that contain pictures into your report, or you can place the pictures themselves into your report. Depending on your requirements, it may be more efficient and easier to point FoxPro to the location of the picture file instead of embedding the data in a general field.

When an OLE container is placed in a report, you are given two choices. You can insert a picture from either a file or a field. When you point Visual FoxPro to a file, the file contents are physically displayed in the report both while you are designing it and at run time as well. The other option is to point to a general field in a table, which will display the picture data only when the report is run.

The third, undocumented way to display pictures in a report is to put a reference to a field which contains absolute path and file information in the 'Picture from file' radio button field contents.

The following steps demonstrate how to achieve this result. To make this work, you must have the FOX.BMP file in the location specified in the INSERT INTO statement. If your location is different, modify the statement accordingly.

  Type each of the following commands in the Command window: CREATE TABLE picttest (Cust_name C(5), Pict_Loc C(30)) INSERT INTO picttest (Cust_name, Pict_Loc) Values ; ("McGoo","C:\VFP\FOX.BMP") CREATE REPORT picttest  Add the Picttest table to the report's data environment by right- clicking the report, and then clicking Data Environment. Right-click the data environment, and click Add. In the Add Table or View dialog box, click Other and select the Picttest table.  In the Report Designer, place a field control in the Detail band on the report. The field's expression value should be: picttest.cust_name   Add a Picture/OLE Bound Control field to the report in the Detail band. In Visual FoxPro 6.0 and later versions, use a Picture/ActiveX Bound Control. Set the field's Picture from File property to: picttest.pict_loc  Run the report. You should see a single record displayed along with the FoxPro logo.</ol>

Additional query words: VFoxMac VFoxWin

Keywords: KB139624

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.