Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

Posted on 2016-09-21
Medium Priority
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 19

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 22
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.
Q2 2017 - Latest Malware & Internet Attacks

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out our latest Quarterly Internet Security Report!


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

Accepted Solution

crystal (strive4peace) - Microsoft MVP, Access earned 2000 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 22
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 22
ID: 41820226
you're welcome ~ happy to help

Featured Post

Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

609 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