Unanswered: Can't open image in report (Runtime Error 2220)
I've done some searching around the forums and found this problem, however everyone seems to figure out the problem and not post it or it is something I'm not dealing with. Anyway, I have an image control in a report and I need to load a picture based on the record. I'm using this code in the form and it works like a dream:
RecipeDir = CurrentDBDir()
If IsNull(Picture1.Value) Then
strPic1 = RecipeDir & "images\NoPicture.jpg"
strPic1 = RecipeDir & "images\" & Picture1.Value
strRecipe1 = strPic1
imgPicture1.Picture = strPic1
I have my pictures in an "images" directory within the DB directory. This works great within the form, but when I do this in the Report Details "OnPrint", It gives me the Runtime Error 2220: MS Access can't open the file "G:\Recipes\images\NoPicture.jpg" however the picture is out there. Am I missing something? Like I said, it works fine in the form. Thanks all in advance!
I'm not sure but I think "imgPicture1.Picture = strPic1" wont always work. Inserting the code into the 'on print event' is probably to late - should be in the "on format" event.
Have you defined a bound image on the report?. Failing that I'd try assigning the image path in the "on format" event. You will need toselect the correct property of the image object. you cant just assign a path to the object as I think the default property of the image object is the image itself (ie the raw data)
As a side note:-
Bear in mind an image that looks good on screen will look pretty poor on print (as a general rule you need to reduce the size (scale) of the image by at least a third and preferably more [screen res is approx 70 pixels, printer res is 330,600,1200 or even 2400 dots per inch]).