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!

Display a web Image in a report access, code issues ... 1

Status
Not open for further replies.

creafter

Technical User
Jul 5, 2018
13
0
0
CH
Hello,

I try to apply the great Strongm code to display a web image in a report but have some issue when I try to "print" the report.

So the link where I found the solution is :
When I try to execute the code I obtain this error message from VBA : "compilation error, bad use of the property" with the '.picture' which is in highlighted

Code:
Option Compare Database

Public Sub Détail_Format(Cancel As Integer, FormatCount As Integer)
Set Image0.Picture = LoadPictureFromURL("[URL unfurl="true"]http://....jpg")[/URL]    'Source file - this text could obviously come from a field in a table, for example
End Sub
where Image0 is an image object in the detail part of the report

I really don't know why this error appear and i don't know how to solve it...
Do you have some idea ?


nb : Excuse my english, it's not my native language

Creafter
 
Sorry I haven't specify that i tried it before and it provide me an other type of VBA Error:
without the "Set" i have "Execution error '-2147467261 (80004003) _ Automation Error _ Invalid pointer
 
Did you add the other code? Does your code compile? Did you use the proper image control?

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
dhookom said:
Did you add the other code? Does your code compile?
Yes I add the other code, I put it in a new module.
I don't have error on this part of code

dhookom said:
Did you use the proper image control?
I think that is the proper image controle but I still have a doubt about it.
I use this "Image" controle :
Capture_oi3ydt.jpg
 
Wrong control. The demo code you worked from is very explicit. It says "Stick an MSForms Image control on your report". Basically it needs to be an ActiveX object tthat can receive an OLE StdPic object. The Access Image control - which you are trying to use - can't.
 
strongm said:
Wrong control.
Ok, sorry i'm not realy comfortable with the ActiveX objects :s

Is this object that I need to create ?
Capture_uoqljo.png


I can't test that now I'm not at my workplace (I'm actualy in switzerland so we probably have an hourly shift)
 
Thank you sooo much !
It work very well, you save me haha :)

EDIT : I test it and It work perfectly with the direct URL past in code but In the "LoadPictureFromURL()" I want to indicate that the path is from a field in a table and I do not succeed ...
I have tried with "DLookup("field","table")" but the incrementing doesn't work :(
What is the right writing to do that ?

Sorry for my basic question but habitually I'm more comfortable on VBA Autocad than on VBA Access ^^



 
Creafter,
Welcome to Tek-tips. It’s customary to mark a thread as a Great Post to give thanks to Strongm.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Ok I will do it :)
Do I need to edit the topic title and to add "Solved" in it ?

creafter said:
I test it and It work perfectly with the direct URL past in code but In the "LoadPictureFromURL()" I want to indicate that the path is from a field in a table and I do not succeed ...
I have tried with "DLookup("field","table")" but the incrementing doesn't work :(
What is the right writing to do that ?
nb: I've edit my last message, do you have the answer to this last little problem?
 
Your report detail should have access to the current record of the datasource. So you should simply be able to refer to it by the field name. So if your underlying table/query has a filed called (e.g) URLFile then the following shopuld work:

Code:
Set Image0.Picture = LoadPictureFromURL(URLFile)


 
I've tried this but a strange error appear : Execution error '2465' Microsoft Access don't found the field "lien1qgis" which is referred to in your expression
However I write clearly that
Code:
Set Image1.Picture = LoadPictureFromURL(lien1qgis)
and the source table of the project is well defined...
Maybe it is because my table is a liked table on a server ? but i don't think because all my forms run well and the others fields of the report run too
 
Sorry, forgot to be complete: you will need at least one control on your report that is bound to the appropriate field. Just stick a textbox in the header, set Visible to false, and set the control source to the appropriate field name(in my example URLFile)
 
Indeed it is that !

I just have to counter the problem of null records. For now I have placed "On error go to" except that it fills me my records null by the last image displayed. I think i can fix that with a loop "if".
I'm looking at it next week, I'm in the weekend and I'm coming back to you if I have a problem, at least you helped me a lot and I thank you for it!
 
Hello !
I come back to you because I was wondering if it is possible to specify a parameter in code that would have for effect to resize the image to the size of the OLE object I insert on my report ?

 
up ?
I really need to have an opinion from you on it
strongm maybe ?
 
What OLE object? The Image control? I which case simply set the Image control's PictureSizeMode property to Stretch
 
Yes it's a OLE ActiveX Microsoft Form 2.0 Image.
Can I use this property like this ? :
SQL:
Image1.PictureSizeMode = fmPictureSizeModeStretch
Is it correct ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top