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.
 
Never have done this before but I did get it to work finally.

In your reports Detail Section create objects called ItemName and ItemImage. They should be bound to your ITEM table by the fields NAME and IMAGEPATH respectively. The object IMAGEPATH should have its VISIBLE property set to FALSE. You can shrink the size of the object down to just a sliver and place it off to the side because it will not be displayed.

Now create an IMAGE object(call it PictureImage) using the IMAGE tool from the toolbar. ACCESS will prompt you with a Common Dialog box to path to the location of a picture document. Go ahead and select any picture(.bmp, .jpg, etc) it doesn't matter which one because we are going to remove this link. Now in your report right-click the new image object and select Properties. There is a Property called Picture which has the pathway to the picure you just selected. Highlight the pathway and delete it.

Now right-click the Detail Section bar of your report and select Properties. Select the OnFormat Event Procedure at the bottom and select from the dropdown Event Procedure item. Now click the build button at the right(. . .) Place the following code in this event procedure:

Me![PictureImage].Properties("Picture") = Me![ImagePath]

This code will load the pathway to your pictures of each detail record into the Picture property of the Picture Image Object in your reports Detail Section.

Give this a try and let me know how it works.

Bob Scriver
 
Sorry, a couple of more properties need to be set. The PictureImage object properties Size Mode and Picture Alignment should be set to Zoom and Center respectively.

You might have to play with the object phisical size by stretching it to your specifications in your report but these two settings will then format the picture without distortion into that object size.

Good luck

Bob Scriver
 
Hi Bob

Well sir you certainly earned a star. I just spent 2 hours at the local Barnes&Noble skimming every Access book they have for anything resembling this issue. I found NOTHING that even remotely touched on the method I was looking for. Every one of those books was stuck on the OLE field type solution where the database grows in size every time you add an image, and they instructed as though there was only one way to do it.

Also, the other posts I had found never mentioned choosing Event Procedure from the OnFormat drop down. I had seen the OnFormat solution, but it never worked because they suggested just setting the OnFormat =Me![PictureImage].Properties("Picture") = Me![ImagePath] .

Thanks again, Bob. Hey, if you ever get into Cold Fusion and need any help id love to return the favor. : )

nic@strantheman.com

nic
 
Glad to help. Thanks for the STAR. I was interested in your project as I was thinking about cataloging my digital pictures and printing out a report of all of the thumbnail images.

I knew there had to be a way to do this. You can create this image object directly and if there is a property for the object then it can be modified through code in most cases.

I am about to retire from the State of Michigan soon an will be entering the consulting business. If I need assistance getting started with Cold Fusion I will certainly drop you a note.
 
Is there a way you can show the images in a Form?

Thanks

Kevin
 
Yes, in the same way you do it in the report.

You have to have a textbox for the Path to the picture on the form. It can be visible to invisible, no matter. If invisible shrink it down small and set it off on the side of the form. Create a picture image with the Picture tool. Pick any .jpg or .bmp image from your file as the source of the picture. After the picture is placed then open up on the properties and remove the Picture property path way. We are going to update it with each new record anyway.

In the On Current event procedure of the form place the following code:

me![PictureImage].picture = me![ImagePath]

You can play around with the size and centering and such of the actual PictureImage object to suit your for but this will refresh the Picture on the form with each record displayed.

Bob Scriver

 
Hi

Thanks for that. I got it working ok. I was just unsure about which event to put the code

Yours

Kevin
 
Hey - i know this thread is getting old but thought i would send a follow up question -

got the pictures on my form working great - thanks.

Q: is there a way to use relative paths to do this - so i can move the folder i have my db in to other PC's without worrying about the complete path name?

thanks,

Ian
 
Sure we can do that but I need to know exactly how you have it setup now path, etc. and how you would want to be moving it to another PC. As long as the final folder where the pictures are stored doesn't change its name we can store in a parameter table the path way for the particular PC that the system is on, that points to that folder.

Example:
Current- d:\picturefolder\pictures\lsBEFSR41.jpg

NEW----- e:\bob\images\lsBEFSR41.jpg

The red portion can be stored as a parameter in the database and only the lsBEFSR41.jpg be stored in each record. We would then cancatenate the two together to create the imagepath for displaying the picture.

Let me know if that is what you need.


Bob Scriver
 
Bob,

I have a DB in a folder SITES. The database stored info about sites we are interested in and for each site i have created a small jpg locater map so the users know where the site is. These are in Sites\maps
I will eventually have to send copies of the DB out to 10-15 other people and currently have NO idea where they will put it in their directories. I didn't want to say "you must put this folder on the C drive" since i hate when people do that to me.

I was hoping for functionality similar to what access provides when you have a hotlink field. If i hot link to a pdf's in Sites\documents\ when i move Sites to a new location Access has no trouble finding the pdf's - since the links are relative.

Your solution would require that I know where they are putting the Sites folder, no?

thanks for the help,

ian
 
Yes, you are right this does require them to install the software in a particular location. Let me work on it for a while where the user is prompted initially for the path to the location of the .jpg's. This way that pathway could be stored in the tables datafiles and be used in the way that I described. Bob Scriver
 
I have found some code that works pretty well for this process. At initial installation, or the first time the database is opened after the installation to some unknown location in the users PC we need to have them path to the location of where they have located the database files. This would be the location of the .jpg's. The following code prompts them to path to that location and pick the target folder. That folder's full path is returned and can be then saved in a database record.


After it is saved it will always be available upon opening the database to be cancatenated on the front of the .jpg file name.

Take a look and test this out. It works quite well for me and I think it will work for you. If you need assistance in setting up the data base storage concept and the daily extracting of the path let me know as I can help with that. Bob Scriver
 
Bob,
thanks - got a button working that lets you set the folder.
Got the image box that links to the field with the complete path name - but this is no longer what i want right? I want a field with the filename and an image box that links to the stored path name and the file name from the folder - right?

Not sure how to get there....

Sorry for the delay - i was in a week long training course and stuck away from my machine.

ian
 
What I would recommend is that you have a table in the front-end application with a single record in it. I call mine tblDBParameters. In this record I have as many fields with stored database information that I use to run my application. In the OnLoad of the main menu I open this form as a recordset and read the first record and store the appropriate data in global variables to be used later. The close the recordset. This is where I would have a field called PathToJPGs Text(100).

Now the first time that the application is opened and I read this table to get the path I would check to see if the field is Null value. This means that we haven't asked the user to path us to the target folder of the jpgs. This is where I would call up the routine to have them select the path and I would store it in the field and save the record. Once done you never have to ask them again as to where the jpgs are found.

Now you have a Global variable - "txtPathToJPGs" that has this path string stored. You can now Use this along with the name of the file to create the full string of the picture to display in the report object.

I hope I haven't been too complicated with this but work with it a while and if you have problems I can assist you with your database. Bob Scriver
 
Hi Bob

Just wanted to say a big thank you for this advice. I was searching for hours to find the answer to this and now I have found it. Many thanks for your help

Regards

Vince Barnes
 
vbtudor: Glad to be of assistance.

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Bob,
This is the thread I've been looking for, however, what should be the data type for field in the table that will contain the imagepath info? Mine is set to "OLE Object". Should it be set to "text"?

Also, why does the code in the event procedure for a report need to be a different syntax than that of a form's code?

I'm having trouble getting both to work. I keep getting an error saying that "the setting for this property is too long" when I use the code for the report. Of course my problems may be related to possibly having the wrong data type specified in the table.

Thanks for your help.

Kevin L.
 
The imagepath should be text as all you are storing is the path to the image to be displayed. It is not really a picture but only the pointer to the picture.

I know that the syntax for forms is different than reports. You must have the correct data type otherwise you will be trying to actually load the embedded immage to the .picture property. That will error. You only want to load the pointer(path) to this property.

Glad I could help you.

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Wanted to add my thanks for this thread, VERY useful, cheers to all who have contributed.

Les
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top