Solved

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

Posted on 2016-09-21
12
94 Views
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
0
Comment
Question by:Dustin Stanley
  • 6
  • 5
12 Comments
 
LVL 13

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
New-Microsoft-Access-Database.zip
0
 

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.
0
 
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.
0
 

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.
0
 
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.
0
 

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.
0
How to Backup Ubuntu to Amazon S3

CloudBerry Backup offers automatic cloud backup and restoration for Linux. It has both GUI and command line interface (CLI) ensuring its flexibility in use. Find out more

 
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
http://www.msaccessgurus.com/Contacts.htm
0
 
LVL 19

Accepted Solution

by:
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
'
   'PARAMETERS
   ' 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)
      Else
         sPathFile = CurrentProject.Path & "\"
      End If
   Else
      If Len(psDirectory & "") > 0 Then
         'starting directory was specified, psDirectory
         sPathFile = psDirectory
      Else
         'psDirectory not specified, use FE directory
         sPathFile = CurrentProject.Path & "\"
      End If
   End If
         
   With Application.FileDialog(3) 'msoFileDialogFilePicker
      .Filters.Clear
      'use pFilter
      .Filters.Add pFilters & " Files" _
               , "*." & pFilters
      'add All files
      .Filters.Add "All Files", "*.*"
      
      If Len(psTitle) > 0 Then
         sStr = psTitle
      Else
         sStr = "Pick a File"
      End If
      .title = sStr
      .InitialFileName = sPathFile
      .AllowMultiSelect = False
      
      If .Show = True Then
         sPathFile = .SelectedItems(1)
      Else
         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
   
Proc_Exit:
   On Error Resume Next
   Set fDialog = Nothing
   Exit Function
  
Proc_Err:
   MsgBox Err.Description, , _
        "ERROR " & Err.Number _
        & "   GetFile_Browse"

   Resume Proc_Exit
   Resume
End Function

Open in new window

0
 

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?
0
 
LVL 19
ID: 41820212
yes

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

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.  ;)
0
 
LVL 19
ID: 41820226
you're welcome ~ happy to help
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hello to you all, I hear of many people congratulate AWS (Amazon Web Services) on how easy it is to spin up and create new EC2 (Elastic Compute Cloud) instances, but then fail and struggle to connect to them using simple tools such as SSH (Secure…
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…
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.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now