PDA

View Full Version : Printing jpg on a report


ABC123

Jay Talbott
03-20-2005, 12:46 PM
Hi. I am using Version 5, latest (Last) build.

I have a very simple appication and want to print a photo on a report. Each record will have a maximum of one photo. All works well when adding the jpg photo to the form, and to the report that prints from the form.

The problem arises when I try to print a report for a record without a photo (which is sometimes necessary). The report prints out the word "Photo". This is not acceptable.

I went to the design mode of the report and checked the box entitled "Allow Shrinking." Now the word "Photo" does not show up. However, neither do any of the other photos in other records.

I tried putting the photo in a RTF, but the report editor balks and says "An RTF object cannot contain an extended memo field."

Willing to use a "crude but effective" method, I can create two reports, and one run if there is a photo attached to a record, and another report it there is no photo, but I cannot figure out how to let Alpha determine whether or not there is a photo with a record.

I have tried searching the board, without success.

Any help would be appreciated.

Regards,
Jay Talbott

Bill Warner
03-20-2005, 01:52 PM
There is an article in the Alpha Newsletter Archive on using bitmaps with a form (http://newsletter.alphasoftware.com/0041207.htm). In this, I used a bitmap called "notavail" when there was no bitmap for a given record, and this bitmap was blank. This might work for you.

Jay Talbott
03-23-2005, 08:40 AM
Bill,

Thanks for your response. Your article was very helpful.

Changing the image on a form was easy, but what I would really like to do is to be able to change an image on a report based on a variable.

Before venturing too far into that jungle, I thought I would "hardcode" an image into the OnInit event of a report. I cannot seem to make the correct image come up on the report.

The attached zip file has 1 table, 1 record in that table, 1 form, 1 report, and (now for something completely different) 2 image files.

I would appreciate any help on setting up the OnInit command for the report, by either hardcoding or using a variable.

Thanks for your time.

Jay Talbott
03-23-2005, 08:54 AM
and now with the zip file attached

Jay Talbott
03-23-2005, 09:16 AM
Now, with the file pared down, it should attach.

I am not actually as stupid as I look.

Okay, maybe I am, but my sense of humor more than makes up for it.

Jay

Stan Mathews
03-23-2005, 09:42 AM
You need to specify a bitmap for the bitmap object on the form when you first place it even if it is a solid color bitmap that matches your form background.

Once that is done you can change the bitmap associated with the object using code for the buttons

bitmap1.bitmap.filename=a5.Get_Path()+chr(92)+"bitmap1.bmp"
bitmap1.bitmap.filename=a5.Get_Path()+chr(92)+"bitmap2.bmp"

Jay Talbott
03-23-2005, 03:07 PM
Stan,

Thanks for your reply. I got the form working. I am trying to get the report to change bitmaps by using an OnInit event.

I followed your instructions without success.

I would have thought your answer would apply to a report, but apparently it does not work the same as a form.

Thanks again for the assistance.

Jay Talbott

Tom Henkel
03-24-2005, 07:31 AM
James,

We need to create ID cards for Customers and Employees.
I have a routine on "on_printinit" that will plug the appropriate bitmap into the report if it exists, or it will put in a "PHOTO NOT AVAILABLE" bitmap.

'Date Created: 15-Mar-2005 04:04:52 PM
'Last Updated: 15-Mar-2005 04:59:27 PM
'Created By : Tom Henkel
'Updated By : Tom Henkel
IF FILE.EXISTS(VAR-"BMPNAME)
bitmap2.bitmap.filename = var-"bmpname
ELSE
bitmap2.bitmap.filename = "o:\IMAGES\NOT_AVAIL.BMP"
END IF

I fire off the print from a form, passing the variable bmpname.

This works just fine.

If you were to be doing a multi-page report, you would need to refresh the variable with each "fetch".


Hope this helps,

Tom