Getting an image from the web

GaelicFatboy

Registered User.
Local time
Today, 20:59
Joined
Apr 17, 2007
Messages
100
I'm looking for some help handling picture images in my database. What I have is a table that stores a string of the filepath for a jpg image stored on the web. What I'm looking to do is retrieve this image and display it using an image object on a form or report. I can open the image as a hyperlink in a web browser but I need the image to be displayed on a form and ultimately a report for a client. All help welcome and very much appreciated.

Cheers

D
 
Show some sample of the filepath stored in the table.
 
Code:
Public Function DownLoadImageFromWeb(URL As String, LocalFileNameToSave As String) As Boolean
    Dim WinHttpReq As Object
    Dim oStream As Object
    Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
    'URL = <<'the url location of the file'>>
    WinHttpReq.Open "GET", URL, False
    WinHttpReq.Send
    URL = WinHttpReq.ResponseBody
    If WinHttpReq.Status = 200 Then
      Set oStream = CreateObject("ADODB.Stream")
      oStream.Open
      oStream.Type = 1
      oStream.Write WinHttpReq.ResponseBody
      On Error Resume Next
      oStream.SaveToFile (LocalFileNameToSave)
      oStream.Close
      DownLoadImageFromWeb=True
    End If
End Sub

example:
If DownLoadImageFromWeb("yourImageURLOnWeb", "D:\sample.png") then
Me.imageOnFormOrReport.Picture = "D:\sample.png"
Else
Me.imageOnFormOrReport.Picture = ""
End If
 
Thanks arnelgp that worked first time, problem solved. You area diamond.

Cheers

D
 

Users who are viewing this thread

Back
Top Bottom