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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picture in my report 34

Status
Not open for further replies.

strantheman

Programmer
Mar 12, 2001
333
0
0
US
Ive searched all of the Access forums, and I haven't found a solution that works. This seems like a very common procedure so im sure someone out there can help.

My ITEM table looks like this:

name | imagepath
-----------------------------------------------
Linksys Cable/DSL Router | d:\lsBEFSR41.jpg
Netgear Switch | d:\ngFS105.jpg

Name is the name of the product, and imagepath is where the photo is stored on my drive. My report pulls NAME, IMAGEPATH from ITEM table for the specified ID. I want to show the name of the product, and its corresponding picture on my report.

For this discussion, lets say the two objects on my report are named itemName and itemImage. I would assume this is as simple as setting some property of itemImage to the IMAGEPATH field, but ive been unable to figure this out. Please provide any help that you can. Id be willing to receive an email with a sample MDB file if thats what I have to do.

thanks in advance, im really hurtin here.
 
I figured out what my problem was... the ActiveX control default name was not CommonDialog1. After I sat there for a while looking at the code figuring out how it worked something popped in my head and figured it out. All I had to do was name the ActiveX control to CommonDialog1 and it works perfectly.

I just had to slow down and think... Just getting to excited about getting everything working I guess...lol

I even added another line to the PictuerImage window to add a hyperlink to the photo so that it would open the picture in a picture viewer. Since I only want to display a small picture in the database this gives me the option to open the image for a more detailed inspection. What do you think? Is using the Hyperlink the way to go about doing this or would there be a better way?

Thank you by the way for your excellent posts and replies you are all invaluable.
 
That's a great idea with the Hyperlink. This saves on loading time to your database. By just using a thumbnail of the pic for the database it will speed things up.

Good luck.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
I've got all the stuff to work excpet one!
I got the images to show on all the forms and reports using the currentproject.path to build and concatenate with the \Images\ and [FileName].
Works just fine and is super slick.
However, since the images are being loaded with code, I'm finding it difficult to EXPORT the report to Word or whatever with the pictures in it.
Has anyone messed with this or know of something (prefrebaly free) that can solve this?
I want to be able to send this document out with all the images loaded onto it.
Ideas?
 
The easiest way to share a report with other people is to print it to a PDF. You don't need to spend thousands on the full Adobe software, there are PDF printer drivers from $9.95. I've also had good results with the open source Ghost Script, but iirc it took a bit more setting up.

An alternative is to use your report to generate a web page. There is an example on my website that shows you how to create "semi-dynamic" web pages.

A final alternative is to save the report as a snapshot, but your end users will need to have the snapshot viewer installed on their machine.

hth

Ben

----------------------------------------------
Ben O'Hara
David W. Fenton said:
We could be confused in exactly the same way, but confusion might be like Nulls, and not comparable.
 
Yeah, I thought PDF would be the best way.
If the Images are not loaded on the other person's computer...is the snapshot embedding the pictures as opposed to just linking to them?
 
AFAIK, the snapshot (and the PDF of course) embed the pictures. I've never tested this, but that is what I assume happens.

Ben

----------------------------------------------
Ben O'Hara
David W. Fenton said:
We could be confused in exactly the same way, but confusion might be like Nulls, and not comparable.
 
Yes, I have run reports with pics and the pic file is embedded in the SnapShot formatted report file. I have found that the SnapShot option works really well. Our office had SS Viewers on everyone's computer and this afforded us the ability to send out canned reports via email easily. The SS format can be selected as an option in code for emailing and attaching a report. Works really well.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
I've been linking picture to my form using a relative path, and for some reason all my paths have been broken! I can't seem to figure it out. This is the code I have been using:

Option Compare Database
Option Explicit

Private Sub Form_AfterUpdate()
CallDisplayImage
End Sub

Private Sub Form_Current()
CallDisplayImage
End Sub

Private Sub Photographlink_AfterUpdate()
CallDisplayImage
End Sub

Private Sub CallDisplayImage()
Me!Status = DisplayImage(Me!ImageFrame, Me!Photographlink)
End Sub


I also use the function (Module1):


Public Function DisplayImage(ctlImageControl As Control, strImagePath As Variant) As String
On Error GoTo Err_DisplayImage

Dim strResult As String
Dim strDatabasePath As String
Dim intSlashLocation As Integer

With ctlImageControl
If IsNull(strImagePath) Then
.Visible = False
strResult = "No image name specified."
Else
If InStr(1, strImagePath, "\") = 0 Then
' Path is relative
strDatabasePath = CurrentProject.FullName
intSlashLocation = InStrRev(strDatabasePath, "\", Len(strDatabasePath))
strDatabasePath = Left(strDatabasePath, intSlashLocation)
strImagePath = strDatabasePath & strImagePath
End If
.Visible = True
.Picture = strImagePath
strResult = "Image found and displayed."
End If
End With

Exit_DisplayImage:
DisplayImage = strResult
Exit Function

Err_DisplayImage:
Select Case Err.Number
Case 2220 ' Can't find the picture.
ctlImageControl.Visible = False
strResult = "Can't find image in the specified name."
Resume Exit_DisplayImage:
Case Else ' Some other error.
MsgBox Err.Number & " " & Err.Description
strResult = "An error occurred displaying image."
Resume Exit_DisplayImage:
End Select
End Function

It seems like all I've been doing is trouble shooting. My ultimate goal is to be able to create databases which store information and photos for fossil discoveries to clients on a CD - hence my desire to use a relative path. These also need to be user friendly so that our employees can enter discoveries and pictures as they are made from computers thoughout the office.
I've noticed in the path that the links are broken if you open the database from access, as opposed to clicking directly on the file name from My Computer.

I save the photos and database in one "Database" folder, which is eventually what gets burned to CD. The photos go into their own folder within the Database folder, typically called JPG or something similar. Thus, the relative path looks like this: JPG\photoCat1.jpg
Any help will be greatly appreciated! Thanks!
 
Why not simply this ?
If InStr(1, strImagePath, "\") = 0 Then
strImagePath = CurrentProject.Path & "\" & strImagePath
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I still haven't taken advantage of all the replies of this thread, but in the first 2 pages worth of replies, I have achieved what I was looking for in the first place. Bob, you are an eminence!! I wish I could get at least 1/16th of your brain!

Thanks again!

- Regulluz!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top