Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image Subform won't display in report 1

Status
Not open for further replies.

Newgrammer

Programmer
Jul 21, 2008
11
US
Hey all,
I'm at the end of the rope with my problem. I have a form that allows users to upload the path's to image files which are then stored in a table and linked to the corresponding record#. I then have a form I created that shows the upload pictures via an unbound image control. That part works fine, where im stuggling is having my report reference the subform correctly. I actually did have it working a few days ago, and have no clue what code I changed cause it to stop functioning.

Where i'm stuck is getting my subform in the report to change the ImageFrame picture based on the corresponding control text box that's hidden on the form. The code I have now is
Code:
sfrmImageReport![ImageFrame].Properties("Picture") = sfrmImageReport![TextBoxLink]
.... TextBoxLink being a text control thats source is the ImagePath in my table. When I attempt to open this I get a run-time error 2113 the value you entered isn't valid for this field.

I'm stumped on where to go from here.

I don't see why it can't seem to point to the text control box rather than a field in a table for the source of the images. Perhaps because it is a subform?
 
Ok i've converted the subform into a subreport and it now works correctly displaying the images. Now where i'm stuck is what code i need for the OnFormat of the main reports Detail section. If I try to use
Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
srepImageReport![ImageFrame].Properties("Picture") = srepImageReport![TextBoxLink]
End Sub
I get Run-time error '2113': The value you entered isn't valid for this field.

What code can I use in the main report to "call" the subreports functions? I think i'm stumped because the code works everywhere EXCEPT the main reports OnFormat.

I must be getting some syntax wrong somewhere, because as I mentioned previously the report was working before I newbie-nuked it.

Any more suggestions?
 
I also use Detail_Print as it loads the images on a page-per-page basis rather than loading them all at the beginning of the report. I found that trick on another post on this forum where the user had 100's of images that were making the report impossible slow to load.
 
If your image control is on the subreport, you should use the subreport section On Print (or On Format) to set the Picture property. This also requires you to have a bound control to the TextBoxLink (image file name).

Duane
Hook'D on Access
MS Access MVP
 
Here's where i'm at right now dhookom:
My main form has the following OnPrint Event

Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
On Error GoTo PictureNotAvailable
srepUploadImageFrame.Properties("Picture") = srepImageLink.Report![ImageLink]
PictureNotAvailable:
    If Err.Number = 2220 Then
    srepUploadImageFrame.Properties("Picture") = "S:\Home\Wes\Engineering Access Database\Icons\NAlg.jpg"
End If
End Sub

And my subreport has the following OnPrint
Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Me![UploadImageFrame].Properties("Picture") = Me![ImageLink]
End Sub

If I open the subreport on it's own it displays each of the Imagelinks perfectly and all of the pictures display fine.

If I open the main report it shows the pictures associated with their linked number correctly, BUT they all display as the PictureNotAvailable image I pointed to.

So I know the subreport works, I just can't get the main report to run the subreport correctly.

I've tried different variations of the
Code:
srepUploadImageFrame.Properties("Picture") = srepImageLink.Report![ImageLink]
code. Some being
Code:
srepUploadImageFrame.Properties("Picture") = srepImageReport![ImageLink]
Code:
srepImagereport![UploadImageFrame].Properties("Picture") = srepImageReport![ImageLink]
All to no avail!

Perhaps I should upload the .mdb file?

 
A follow-up to the above:

I've created a new report using a template to see if that might help solve the problem. Now the pictures do display correctly with:
Code:
srepImageReport!UploadImageFrame.Properties("Picture") = srepImageReport![ImageLink]
but ONLY if I don't make a parent/child link of the Report field. The report field is an autonumber assigned to each new entry and is also the field I use to identify each image. I'll continue fiddling and hopefully come up with a solution, hopefully someone has had something similiar to this come up.
 
This code will always run the PictureNotAvailable: code because there is nothing to stop the code or exit the sub.

Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
On Error GoTo PictureNotAvailable
srepUploadImageFrame.Properties("Picture") = srepImageLink.Report![ImageLink]
PictureNotAvailable:
    If Err.Number = 2220 Then
    srepUploadImageFrame.Properties("Picture") = "S:\Home\Wes\Engineering Access Database\Icons\NAlg.jpg"
End If
End Sub
I don't understand why you would run code in the main report to set stuff in the subreport.


Duane
Hook'D on Access
MS Access MVP
 
You are correct dhookom, I didn't need to run that code on the main report.

What I did have to do to get this to work though is in the Subreports Data tab set the LinkMasterFields to actually specify exactly what table. So by default, Access was doing the Child field as Report and the Master field as report and it was either not showing anything or giving an object not found error. When I set the Master field to tblInspectionReport.Report and Child to Report it works fine.

I think this issue has been resolved for now, thank you for the assistance.
 
That most definetly was it!

Once I went through and redid my tables, forms and reports to follow proper naming conventions everything worked fine. So now instead of Report I have lngReportNumber and it links perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top