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!

Picture in my report 34

Status
Not open for further replies.

strantheman

Programmer
Mar 12, 2001
333
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.
 
Glad that I could help you with this.

Bob Scriver

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

 
Okay, I have a form that I am trying to display pictures based on the selection from a combo box. Everyhting is working except I can't get the pictures to work. I read and tried to mimic all of the above statements, but I keep getting this error: the object doesn't contain the automation object "me". I am not a ACC2k guru, so can someone inform me what that error means?

It's getting frustrating -- I'm down to the last thing and it not working for me - Thanks!

 
LadyDev: Post the code that is in the AfterUpdate event procedure of your combobox. Also, indicate the line that the error is stopping on. The highlighted line in when it goes to the code display.

Bob Scriver

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

 
This is the only code I have on the form. I placed (as stated above) the me![PictureImage].picture = me![ImagePath]
in the onCurrent section of the form. Got the image on the form, plus the textbox (txtHelpFulDisplay). What I don't understand is how by doing that gets the respective picture to correspond to the subform selection.

Option Compare Database
Option Explicit
Private Sub cmboChoice_AfterUpdate()
Me!frmCarsAvailable.Form.Requery
End Sub

Private Sub grpSelect_AfterUpdate()
Me.cmboChoice.Requery
Me.cmboChoice.SetFocus
Me.cmboChoice.Dropdown
If IsNull(Me.cmboChoice.Column(1)) Then Me!frmCarsAvailable.Form.Requery
End Sub
 
What is in the control txtHelpFulDisplay? Also, do you have a control on the form that has a control source of the path to picture that you want displayed? This is a must. It can be visible or invisible. But, it has to be there. This is the control that is going to load your picture to your picture image.

Bob Scriver

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

 
Control Source ="Documents pertaining to " & [cmboChoice] & ":" (txtHelpFulDisplay)

That control you sepak of is the txtbox.
 
Which control has the path to the picture for this record?

Bob Scriver

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

 
Okay, I am confused, even more. I placed an image control on the form. Then I added a picture through the picture control (c:\...); afterwhich I removed, becuase I placed the me![PictureImage].picture = me![ImagePath] on the onCurrent event of the form. What other control are you talking about? This seemed to easier when I read it.
 
Let me explain:
me![PictureImage].picture = me![ImagePath]

There needs to be two controls on your form to make this work.

Image Control: I called it PictureImage. In the above code change it to the name of your Image control or change your image control to PictureImage.

Text Control: I called it ImagePath. In the above code change it to the name of your control that is linked by its control source to a field in your table with the image path or change the name of your text control to be called Imagepath.

Now with those two controls and that one line of code in the OnCurrent Event Procedure you can move through your records and the correct immage will be loaded to the forms Image Control.

Bob Scriver

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

 
Okay, I placed another textbox on the form (txtPath) and added this additional code to the OnCurrent and AfterUpdate events of the form. Still nothing. I am not getting an error, but I am not getting the image either.


Option Compare Database
Option Explicit
Private Sub cmboChoice_AfterUpdate()
Me!frmCarsAvailable.Form.Requery
End Sub

Private Sub Form_AfterUpdate()

On Error Resume Next
Me![ImageFrame].Picture = Me![FilePath] & Me![FileName]
Me![txtPath] = Me![FilePath] & Me![FileName]

End Sub

Private Sub Form_Current()
On Error Resume Next
Me![ImageFrame].Picture = Me![FilePath] & Me![FileName]
Me![txtPath] = Me![FilePath] & Me![FileName]

End Sub

Private Sub grpSelect_AfterUpdate()
Me.cmboChoice.Requery
Me.cmboChoice.SetFocus
Me.cmboChoice.Dropdown
If IsNull(Me.cmboChoice.Column(1)) Then Me!frmCarsAvailable.Form.Requery
End Sub
 
Okay, let me change it to your terminology. Posted my message before I saw yours.
 
Nope...nothing happening, except I now have that previous error back.
 
When you get this error is there code being displayed? The only place this can be happening is in the OnCurrent Event Procedure where that one line of code goes. ACCESS is not recognizing the terminology ME. Put a STOP command in front of this line of code. When it stops click on the Debug window and type in ?me.imagepath then Enter. See what it displays. Should be the path to the picture. The word me should not be surrounded by square brackets. I have seen access do this at times.

let me know what happens now. Don't get discouraged we will figure this out. If you want to just send me a db with the form only and let me take a look I am willing. See my profile for email address.

Bob Scriver

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

 
It happens before the form opens.

Someone told me this: The object Me only applies in a class module, as it represents the current instance of the class. You could use [Form] in the event properties dialog to achieve practically the same thing:
=[Form].PictureImage.Picture=[Form].ImagePath

I send a copy of the form.
 
Okay, we have resolved the problem. The issue here is that your form has a subform with multiple records each with a different path to the picture. The above code was designed for the main form having the field with the path to the picture.

So, what was needed was to add the path field to the subforms underlying Select statement. Add a control to the subform with the path field as the control source and make it invisible. Then in the OnCurrent event procedure of the subform make the assignment of the path control to the main forms .picture property of Image control.

Everthing is working now. Good luck with your project.

Bob Scriver

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

 
OK I have a form working that displays pictures successfully based on a text field holding the name of the picture. I have added a multitude of subforms based on crosstab queries that have slowed my form down. Now when I click through my main form records quickly enough I get the following message: "Method 'Picture' of object '_image' failed" The error number is -2147417848
Any help GRATEFULLY received. Thanks for taking time to read this.
JeanS
 
I'm another user who's benefited greatly from this thread. Thanks!

By the way, if you aren't too ashamed to blatantly rip off Microsoft, the Northwind sample database has an excellent little form under "Employees" that does it all for you (the form part).
 
Nope, I'm not ashamed to let Microsoft give me a running start on the pictures. In fact that is exactly what I did. It worked OK for .bmp and for .jpg UNTIL I added some subforms. Then the .jpg files blew up but the .bmp worked fine.
 
yeah, i figure Microsoft has ripped me off enough times....

by the way, is there a way to make scriverb's solution able to grow or shrink? i've got a report where some people have photos and others don't, and i'd like to get rid of the big empty spaces. Can Grow and Can Shrink aren't available in picture boxes.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top