Show web image in report
Show web image in report
(OP)
I'm trying to include an online map for a UK postcode in an Access report.
I'd already tried using a web browser control exactly as I'd used in a form.
It doesn't work
Then I found this old thread via a Google search http://www.tek-tips.com/viewthread.cfm?qid=1758167
The solution by strongm using a standard image control looked like EXACTLY what I needed.
However I get an 'invalid use of property' error on this line when its in the Detail_Format event:
I moved it to the Report_Load event - no error but the control is empty
I tried adding a field WebURL _="https://www.openstreetmap.org/search?query=" & Me.Postcode) to the report.
e.g. "https://www.openstreetmap.org/search?query=BS25 5NB"
However I get the same results in both places

I also tried hard coding a web image - the one in strongm's post.
"http://www.blogcdn.com/www.engadget.com/media/2012..."
Exactly the same result so its nothing to do with the space in the postcode
EDIT:
Just compiled and it barfs at the Set Image0.Picture line in the Report_Load section
Any ideas?
Colin
I'd already tried using a web browser control exactly as I'd used in a form.
It doesn't work
Then I found this old thread via a Google search http://www.tek-tips.com/viewthread.cfm?qid=1758167
The solution by strongm using a standard image control looked like EXACTLY what I needed.
However I get an 'invalid use of property' error on this line when its in the Detail_Format event:
CODE --> Me.Postcode)
Set Image0.Picture = LoadPictureFromURL("https://www.openstreetmap.org/search?query=" & Me.Postcode)
I moved it to the Report_Load event - no error but the control is empty
I tried adding a field WebURL _="https://www.openstreetmap.org/search?query=" & Me.Postcode) to the report.
e.g. "https://www.openstreetmap.org/search?query=BS25 5NB"
However I get the same results in both places

I also tried hard coding a web image - the one in strongm's post.
"http://www.blogcdn.com/www.engadget.com/media/2012..."
Exactly the same result so its nothing to do with the space in the postcode
EDIT:
Just compiled and it barfs at the Set Image0.Picture line in the Report_Load section
Any ideas?
Colin
RE: Show web image in report
Skip,
Just traded in my OLD subtlety...
for a NUance!
RE: Show web image in report
Thanks for the link to the VERY recent thread!
Exactly the same issue as me
Apologies for not doing a forum search first
I know I've followed strongm's instructions exactly
I'm using Access 2010 32-bit though I doubt that's relevant
Colin
RE: Show web image in report
CODE -->
This allowed me to include various image from web sites in my reports without error.
However, it also failed when I tried to use it to create a 'static' map from online map providers (Open Street Map / Bing / Google / Michelin)
Fortunately there was a much easier solution.
The Google Maps API is free to use and this allows you to download 'static' maps.
It is very simple to use.
See this link for detailed instructions & to get an API key: Google Maps for developers
RE: Show web image in report
But that's not alternative code. That's exactly the same as my code, even down to the comment, from the thread you referenced in your first post.
>it also failed when I tried to use it to create a 'static' map from online map providers
Well, it would fail. As I said before, this code is for downloading an image. It is not a screen scraper. It doesn't turn a web page into a bitmap and download that. It expects to find an image as the target of the URL. Which is of course exactly what the Google Static Maps API actually provides: a URL to an image.
Having said that - there is one bit of critical info missing in my original code: the Image control needs to be the MS Forms ActiveX image control, not the Access image control.
RE: Show web image in report
It was late & I copied / pasted your code as you correctly pointed out.
Just to make things worse, I tried to be 'helpful' by also pasting in the other thread
OK - the alternative code I found (can't remember where or the author) is as follows:
CODE -->
That does work correctly with a standard Access image control on standard web images such as the link in strongm's post.
I used that code to download the 'static' map image defined using Google Maps API
I've also re-tested strongm's code using the ActiveX MS Forms image control & his example image & it works perfectly
RE: Show web image in report
RE: Show web image in report
However for the static Google maps I am using, it is instantaneous.
I also overwrite the same map.BMP file each time I change the postcode to avoid wasting disk space.