×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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 : https://www.tek-tips.com/viewthread.cfm?qid=175816...

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 --> vba

Option Compare Database

Public Sub Détail_Format(Cancel As Integer, FormatCount As Integer)
Set Image0.Picture = LoadPictureFromURL("http://....jpg")    '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

RE: Display a web Image in a report access, code issues ...

I would try remove the word "Set"

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: Display a web Image in a report access, code issues ...

(OP)
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 "

RE: Display a web Image in a report access, code issues ...

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

RE: Display a web Image in a report access, code issues ...

(OP)

Quote (dhookom)

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

Quote (dhookom)

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 :

RE: Display a web Image in a report access, code issues ...

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.

RE: Display a web Image in a report access, code issues ...

(OP)

Quote (strongm)

Wrong control.
Ok, sorry i'm not realy comfortable with the ActiveX objects :s

Is this object that I need to create ?


I can't test that now I'm not at my workplace (I'm actualy in switzerland so we probably have an hourly shift)

RE: Display a web Image in a report access, code issues ...

That's the one

RE: Display a web Image in a report access, code issues ...

(OP)
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 ^^



RE: Display a web Image in a report access, code issues ...

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

RE: Display a web Image in a report access, code issues ...

(OP)
Ok I will do it :)
Do I need to edit the topic title and to add "Solved" in it ?

Quote (creafter)

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?

RE: Display a web Image in a report access, code issues ...

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) 


RE: Display a web Image in a report access, code issues ...

(OP)
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 --> vba

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

RE: Display a web Image in a report access, code issues ...

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)

RE: Display a web Image in a report access, code issues ...

(OP)
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!

RE: Display a web Image in a report access, code issues ...

(OP)
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 ?

RE: Display a web Image in a report access, code issues ...

(OP)
up ?
I really need to have an opinion from you on it
strongm maybe ?

RE: Display a web Image in a report access, code issues ...

What OLE object? The Image control? I which case simply set the Image control's PictureSizeMode property to Stretch

RE: Display a web Image in a report access, code issues ...

(OP)
Yes it's a OLE ActiveX Microsoft Form 2.0 Image.
Can I use this property like this ? :

CODE --> sql

Image1.PictureSizeMode = fmPictureSizeModeStretch 
Is it correct ?

RE: Display a web Image in a report access, code issues ...

Sure, but you might as well set it at design time

RE: Display a web Image in a report access, code issues ...

(OP)
Ok :) I will try it tomorrow at work.

Quote (strongm)

you might as well set it at design time
I don't understand what you mean by "design time"... you want to say when I create the OLE and when I size it ?

RE: Display a web Image in a report access, code issues ...

>when I create the OLE and when I size it ?

yep

RE: Display a web Image in a report access, code issues ...

(OP)
I have a large amout of picture and they don't have the same size so I can't design an unique size form my OLE image.

I have try the property and it work perfectly, my project is now done.
Thank you a lot for all your help !
thumbsup2

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close