By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 2,220 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

How to add image control

P: 5
Hi,

I've created on a form an event to create a new report. I've almost done but can't solve one problem with newly created image control in the report.

I have a source with image path but i couldn't find solution how to add this path info to the control.


Below is the part of my code. I receive error on 15th line: "Run-time error'438': object doesn't support this property or method". Please give some advises.

Expand|Select|Wrap|Line Numbers
  1. Dim txtPhotoID As Access.Image
  2.  
  3. Set rpt = CreateReport
  4. strReportName = rpt.Name
  5.  
  6. title = "Report1"
  7. DoCmd.RunCommand acCmdDesignView
  8.  
  9. rpt.RecordSource = "SELECT ImagePathlink FROM test1;"
  10.  
  11. Set txtPhotoID = CreateReportControl(rpt.Name, acImage, _
  12.          acGroupLevel2Header, , , 200, 200)
  13.          txtPhotoID.SizeToFit
  14.          txtPhotoID.Name = "CatgPhoto"
  15.          rpt.Controls("CatgPhoto").ControlSource = "ImagePathlink"
  16.  
  17.  
Mar 7 '12 #1
Share this Question
Share on Google+
10 Replies


P: 11
You can't bind an Image control to a datasource, you could try a bound Object control instead
Mar 7 '12 #2

P: 5
Thanks for your reply ChrisPadgham
I'm not very advanced programmer. I'm not sure where to change and how to change my image to bound object :(
I've tried only this

rpt.Controls("CatgPhoto").Picture= "ImagePathlink"

But received message "can't open the file "ImagePathlink". In this case I understand that "ImagePathlink" is unserstood as the path of file. By the way I use Access 2007.
Mar 8 '12 #3

100+
P: 759
I assume that ImagePathlink is a variable where you store the full path for your image. So the quotes are not necessary:
Expand|Select|Wrap|Line Numbers
  1. rpt.Controls("CatgPhoto").Picture= ImagePathlink
This is one face of your problem. I think that will not solve your main problem: To show pic in the report.

I post now for subscribe purpose but I'll try to solve your problem because is an interesting one.
Mar 9 '12 #4

100+
P: 759
This work very well for me (see attachment) with no programming.
Of course you must customize the addresses.

Let me know if this is what you are looking for or I misunderstand your problem.
Attached Files
File Type: zip PicturesInReport.zip (21.8 KB, 428 views)
Mar 9 '12 #5

P: 5
Thank for your help. Your example do not help me in this case. If I leave my code only to create image control without adding any control source (ImagePathlink) and then I go to the new created report and insert a control source ImagePathlink - I see pictures. The problem is I don't know how to create report and "tell" in the creation code to put control source.
Mar 10 '12 #6

100+
P: 759
Thanks (again) to MMcCarthy : http://bytes.com/topic/access/insigh...port-using-vba

I can develop this code:

Expand|Select|Wrap|Line Numbers
  1. Dim rpt As Report
  2.     Set rpt = CreateReport
  3.     With rpt
  4.         .Caption = "Report1"
  5.         .RecordSource = "SELECT ImagePathlink FROM test1;"
  6.     End With
  7.  
  8.     DoCmd.RunCommand acCmdDesignView
  9.  
  10. Dim imgPhotoID As Access.Image
  11.  
  12. Set imgPhotoID = CreateReportControl(rpt.Name, acImage, _
  13.          acDetail, , "ImagePathlink", 200, 200)
  14.          imgPhotoID.SizeToFit
  15.  
  16. 'This approach give me an error because -acGroupLevel2Header- not because "ImagePathlink"
  17. 'Set imgPhotoID = CreateReportControl(rpt.Name, acImage, _
  18. '         acGroupLevel2Header, , "ImagePathlink", 200, 200)
  19. '         imgPhotoID.SizeToFit
Mar 10 '12 #7

P: 5
Thank you for your reply. I made changes according to your comments but when I look at the created report - no picture source is attached. I added my code.
Attached Files
File Type: zip CreateReport.zip (76.9 KB, 136 views)
Mar 15 '12 #8

100+
P: 759
I can't open your database. I use 2007.

Sorry but I can't see any reason to don't work for you.
Now I attach the database. You must change the pics addresses according to your pictures paths.
Attached Files
File Type: zip PicturesInReport.zip (39.5 KB, 215 views)
Mar 15 '12 #9

P: 5
Sorry, If you think that I want you to do my work, I put database to show that your code doesn't work in my case. In your example I changed the path of image and after I pressed button "Create report", I received white paper - no images. I can send you a printscreen to if you are interested in. But anyway. thank you for your assitants, I will try to solve this problem in other way. Thank you again.
Mar 16 '12 #10

100+
P: 759
Paukste !
Is how (and how I like) to learn myself: by analyze others code. It is why I provide you code and, finally, the database.
I can't understand why don't work for you.
Sorry for that.

If anyone else can make testes I'll thank he (she) very much.
Mar 16 '12 #11

Post your reply

Sign in to post your reply or Sign up for a free account.