MS Access Image Thumbnail or Display on Form From Attachment or URL

Posted on 2016-09-21
Last Modified: 2016-09-28
I am using MS Access 2016 and I am needing a way to have a button that I click and it will open up a file browser and allow me to navigate to a file capture that files path and then display it in my new Access Database Form. I would like to have a thumbnail image around 3x3 Inches in the upper corner of my product form. Best I wish I could get a image controller display so i can click on the image and then a image controller pops up and allows me to see it full resolution zoom in and out capabilities. I have been using a desktop application database software previously and it has these function but it is very unreliable so i am building my own.  Any help and direction would be very appreciated. I also keep all my images on a ec2 S3 bucket and I keep the URLs so I can link back to them if this can help. I have attached two photos here of the previous Database software I was using and my new Access Database Form. The next photo I attached is of the previous software image display enlarger Thank you all.
Database ComaprisonDatabase IMAGE ENLARGER
Question by:Dustin Stanley
  • 6
  • 5
LVL 15

Expert Comment

by:John Tsioumpris
ID: 41808681
If you can "download" the image then you use it with Imagecontrol.Picture or you can store the image as byte array and use PictureData
I have a small sample

Author Comment

by:Dustin Stanley
ID: 41808696
Ok Will this Store the image in the database or link to a image outside the database. I truly prefer to link outside to another folder or URL to keep things slim and moving fast. I really appreciate the help. I have tried out several forums in the last month and this one seems to be really good and helpful. I like it a lot.
LVL 19
ID: 41820068
If you have URLs stored in the database, you can create a button on the form that with the control holding the URL (ControlSource is field in your table) to open the URL in a browser window using:
   dim sURL as string
   with me.URL_controlname
      if not isnull(.value) then
         sURL = .value
         application.followhyperlink sURL
      end if
   end with

Open in new window

Alternately, a web browser control can be used inside Access but I find that more limiting for scrolling and being able to look at more than one page at a time.
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.


Author Comment

by:Dustin Stanley
ID: 41820099
Is the browser window you state as in my browser like IE or chrome or on the form itself?

 I have been able to just state that the URL is a hyperlink and click on it directly and open up a browser in chrome fine. I also have set up a browser control and been able to view it but the images are to large.

 I would like to store maybe the first image in the database directly as a thumbnail image to view like in the photo above and the rest could be on a hyperlink or such. But if someway I could use something like the browser control but be able to fit the image to the Browser control on the form without new links and resizing images on my URLs. That would be best. So the database isn't slowed down by image data.
LVL 19
ID: 41820122
the browser would be whatever is set as your default browser.

> "store maybe the first image in the database directly"

just like URLs can be stored, path\filenames can be stored.  It is much better to keep images in external files.  I often create an \images directory below the back-end database (so far, your database is not split into front-end (FE) and back-end (BE)). The BE has tables and the FE has forms, reports, queries, macros, and modules. Each user will have their own copy of the FE once it is split and the database is deployed.

Author Comment

by:Dustin Stanley
ID: 41820159
That is what I am working on now is the forms for inserting information. What would be a good command button to capture the link path way for the user on the FE to just click button, browse, choose image.
LVL 19
ID: 41820169
best to copy or move the file to an images directory after they browse to it since others who use the database may not have the same path.  I then store images relative to where the back-end is, so I don't actually store the path (usually), just the filename.  An example of how to do that is in my Contacts database when you click the attachments (push-pin) icon here:

Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments
LVL 19

Accepted Solution

crystal (strive4peace) - Microsoft MVP, Access earned 500 total points
ID: 41820175
to answer your question though, here is a function to return path\filename (maybe a better method than what I may have used in Contacts, can't remember what I did)
Function GetFile_Browse( _
   Optional psPathFile As String = "" _
   , Optional psDirectory As String = "" _
   , Optional psTitle As String = "" _
   , Optional pFilters As String = "JPG" _
   , Optional psReturnFilenameOnly As String _
   ) As String
'Requires reference to Microsoft Office #.0 Object Library.
's4p 130325...141204
   ' psPathFile -- if sent, will be parsed for the start directory
   ' psDirectory -- if psPathFile not sent, specifies start directory. default is the FE directory.
   ' psTitle = Titlebar of the dialog box
   ' pFilters -- file extension to browse to, ie: JPG, PDF, XLS*
   ' psReturnFilenameOnly - returns the name of the file stripped from the path if sent
   On Error GoTo Proc_Err
   Dim fDialog As Object 'late binding
'   Dim fDialog As Office.FileDialog 'early binding
   Dim varFile As Variant
   Dim sPathFile As String _
      , sStr As String _
      , nPos As Long
   If Len(psPathFile) > 0 Then
      'get the directory from psPathFile
      nPos = InStrRev(psPathFile, "\")
      If nPos > 0 Then
         psDirectory = Left(psPathFile, nPos)
         sPathFile = CurrentProject.Path & "\"
      End If
      If Len(psDirectory & "") > 0 Then
         'starting directory was specified, psDirectory
         sPathFile = psDirectory
         'psDirectory not specified, use FE directory
         sPathFile = CurrentProject.Path & "\"
      End If
   End If
   With Application.FileDialog(3) 'msoFileDialogFilePicker
      'use pFilter
      .Filters.Add pFilters & " Files" _
               , "*." & pFilters
      'add All files
      .Filters.Add "All Files", "*.*"
      If Len(psTitle) > 0 Then
         sStr = psTitle
         sStr = "Pick a File"
      End If
      .title = sStr
      .InitialFileName = sPathFile
      .AllowMultiSelect = False
      If .Show = True Then
         sPathFile = .SelectedItems(1)
         Exit Function
      End If
   End With 'fDialog

   '-------- set return filename
   psReturnFilenameOnly = ""
   nPos = InStrRev(psPathFile, "\")
   If nPos > 0 Then
      psReturnFilenameOnly = Mid(psPathFile, nPos + 1)
   End If
   GetFile_Browse = sPathFile
   On Error Resume Next
   Set fDialog = Nothing
   Exit Function
   MsgBox Err.Description, , _
        "ERROR " & Err.Number _
        & "   GetFile_Browse"

   Resume Proc_Exit
End Function

Open in new window


Author Comment

by:Dustin Stanley
ID: 41820181
Would i use a image controller to display the image in the form?

Also what about the view larger button that is in my past database software. Is there a way for Access to do that?
LVL 19
ID: 41820212

yes -- create another form with an image icon that is bigger that can pop up

Author Closing Comment

by:Dustin Stanley
ID: 41820215
Thank you I am glad someone came along on that one so when I got there I could do it.  I thought I was abandoned.  ;)
LVL 19
ID: 41820226
you're welcome ~ happy to help

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you are thinking of adopting cloud services, or just curious as to what ‘the cloud’ can offer then the leader according to Gartner for Infrastructure as a Service (IaaS) is Amazon Web Services (AWS).  When I started using AWS I was completely new…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question