Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

www source for (image) object, possible?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bb67dart@gmail.com - 09 May 2008 17:22 GMT
Hi all..

Is there a way to assign the source of an image object to a www
location? What I'm looking to do is to have an image object that I can
freely change on a website, that will be loaded each time a user opens
a form.

Specifically, this database is for health intervention data and we are
developing and updating certain guidelines for the intervention as we
go. Ideally I'd be able to upload a new image (containing text of the
guidelines) to a website, and have that image loaded each time the
user clicks opens the "guidelines" - so they would always get the
latest information that had been posted on the website.

Any ideas are appreciated, thanks.
Damon Heron - 10 May 2008 20:18 GMT
This might work, I have never tried it, but I saved it in my files a long
time ago.  In a module, put:

Option Compare Database
Option Explicit

Private Declare Function GetTempPath Lib "kernel32" _
                   Alias "GetTempPathA" ( _
                   ByVal nBufferLength As Long, _
                   ByVal lpBuffer As String) _
                   As Long

Private Declare Function GetTempFileName Lib "kernel32" _
                   Alias "GetTempFileNameA" ( _
                   ByVal lpszPath As String, _
                   ByVal lpPrefixString As String, _
                   ByVal wUnique As Long, _
                   ByVal lpTempFileName As String) _
                   As Long

Private Const MAX_PATH = 255

Public Function DownloadPicture(ByVal strURL As String) As String

   Dim xmlhttp     As Object
   Dim oStream     As Object
   Dim strTmp     As String

   On Error GoTo Err_DownloadPicture

   Set xmlhttp = CreateObject("Msxml2.XMLHTTP")
   With xmlhttp
       .Open "GET", strURL, False
       .setRequestHeader "CONTENT-TYPE", "image/jpeg"
       .send
       Do Until .readyState = 4
           DoEvents
       Loop
   End With

   strTmp = GetTmpFileName(Right(strURL, 3))

   Set oStream = CreateObject("ADODB.Stream")
   With oStream
       .Mode = 3  'adModeReadWrite
       '.Charset = "iso-8859-1"
       .Type = 1  'adTypeBinary
       .Open
       .Write (xmlhttp.responseBody)
       .SaveToFile strTmp
   End With

   Set oStream = Nothing
   Set xmlhttp = Nothing

   If Dir(strTmp) <> "" Then
     If FileLen(strTmp) > 0 Then
         DownloadPicture = strTmp
     End If
   End If

Exit_DownloadPicture:
   Exit Function
Err_DownloadPicture:
   MsgBox Err.Description
   Resume Exit_DownloadPicture
End Function

Private Function GetTmpFileName(sSuffix As String) As String

   Dim strPath       As String, _
       strFolder     As String
   Dim lngResult     As Long

   strFolder = String(MAX_PATH, 0)
   lngResult = GetTempPath(MAX_PATH, strFolder)
   strFolder = Left$(strFolder, InStr(1, strFolder, Chr$(0)) - 1)

   strPath = String(MAX_PATH, 0)
   lngResult = GetTempFileName(strFolder, "PIC", 0, strPath)
   strPath = Left$(strPath, InStr(1, strPath, Chr$(0)) - 1)
   GetTmpFileName = Replace(strPath, ".tmp", "." & sSuffix)

End Function
*****************************************
Then call the function like this:

Me!picfoto.Picture = DownloadPicture(Me!txtURL)
This assumes you have an image object called picfoto, and a textbox called
txtURL that contains the full internet address of the jpg file- it should
include the name and extension:  http:/www.mywebsite.com/mypic.jpg

Let me know if it works for you.
Damon

> Hi all..
>
[quoted text clipped - 11 lines]
>
> Any ideas are appreciated, thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.