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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
LVL 17

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 21
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.
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.


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

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 21
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 21
ID: 41820226
you're welcome ~ happy to help

Featured Post

Retailers - Is your network secure?

With the prevalence of social media & networking tools, for retailers, reputation is critical. Have you considered the impact your network security could have in your customer's experience? Learn more in our Retail Security Resource Kit Today!

Question has a verified solution.

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

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…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

729 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