Access 2013 - Image Field - Double Click to enlarge and edit

Posted on 2013-12-06
Last Modified: 2013-12-12
Access 2013 Database

I have a form that assigns a picture to an image field and I'd like to be  able to double click the image field and see an enlarged copy of the photo and then when I close have the option to save the image with any edits I might make

Is this possible? If so please help me get started with the process

Question by:rogerdjr
  • 3
  • 3
LVL 21
ID: 39702822
Is this possible?
Maybe ...

What image editor software will you be using?  Does it support automation?

*** Note: Every computer that will run your database and need to edit images will have to have the image editing software installed.

What is built-in

Edit images from within Access

If the computer that runs your database has the graphics program used to create your images, and that graphics program supports being started from within Access, you can edit images directly from your form. If you aren't sure whether your graphics program supports that functionality, the best way to find out is to follow the steps in these sections and try to edit a bound or unbound image.

 Note   If you're editing embedded images, these steps only change one instance of the image. These steps do not change the original image. Also, if you embed an image more than once, you must change each instance of the embedded file.

Custom Solutions

You could write custom VBA code to do it if your have an image editor that supports automation.

1) write the image out to a (temp) file
2) launch the editor
3) check to see if the file have changed
4) If changed then:
- 4a) delete the original image
- 4b) insert the updated image
5) delete the temp images.

There are third-party controls you can purchase that will do this.

Check out:

1) GdPicture

GdPicture.NET series of toolkits and plugins provide both .NET and ActiveX controls so , besides .NET platforms, you can use it in many other different platforms such as HTML page, SilverLight app., Visual FoxPro, Delphi, VB6, MSAccess and all other IDE supporting ActiveX.

Main Features

    Resize and Scale an image using nine different interpolation algorithms.
    Create HQ thumbnails.
    Image filters include Per Pixel Filters, Convulsion Filters, Edge Detection Filters, Bilinear Filters and Displacement Filters.
    Effects and Filters include Median, Gaussian,Unsharp Mask, Despeckle, FloodFill, Red-eye removal, Emboss, Sharpen, Blur, Edge Detection,Twirl, Chroma Key Background Removal…
    Color anti-aliasing and smoothing.
    Scale a bitonal bitmap to a gray bitmap.
    Advanced image-merging support.
    Area and region processing.
    Standard rotations: 90°, 180°, 270°.
    Mirror, flip and invert an image.
    Angle rotation with 1/1000 degree increments.
    Adjust contrast, brightness, gamma and saturation.
    Bitonal Image Enhancement: repair characters, remove lines and fill holes.

2) DBPix - The Image Control for Microsoft® Access
Add images to Access databases, easily and efficiently with DBPix, the High-Performance Image Control for Access.

3) AccessImagine ActiveX
browse and load, drag-n-drop, paste from clipboard, aquire from scanner or web-cam images right to database, in-place cropping tool, undo, old OLE data support, display HTTP (web) images, JPEG, BMP, GIF and PNG  file formats support, store images in JPEG format to save space, external image storage with automatic maintaince, anti-aliased image display, automatic resampling, continuous forms solution, on-click full-screen image display fitted to screen or with panning tool, opens image on-click in editing application, 90 degrees image rotating, VBA scripting image manipulations, SQL Servers and .NET languages support, x64.

What I find works best:

Do not store the images in the database. Only store the path to the file.

To edit the file I use ShellExec to open the file in the default image editor. You could use Sell to specific the program and file path.

That is it. That easy. The key is the changes must be saved back to the original file name.

Author Comment

ID: 39703237
I use microsoft windows 8 paint version 6.3 as my default photo editor - but I would be fine with opening the photo in acrobat or some other "basic" photo viewer.

As you suggested I store the file & path in the database not the photo.

How would I "To edit the file I use ShellExec to open the file in the default image editor. You could use Sell to specific the program and file path. "
LVL 21

Accepted Solution

Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 500 total points
ID: 39703570
Here is the code I use for ShellExec

I would place this code in a standard code module named something like modShellExec.
Option Compare Database
Option Explicit

Public Const SW_HIDE = 0
Public Const SW_NORMAL = 1
Public Const SW_SHOWNORMAL = 1
Public Const SW_MAXIMIZE = 3
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9
Public Const SW_MAX = 10
Public Const SW_SHOWDEFAULT = 10

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Function bimShellOpenFile(strFilePath As String, lngShowCmd As Long) As Long
' opens the file passed by calling windows
' the file should be opened into the app associated with the files type

Dim r As Long
Dim hwnd As Long

r = ShellExecute(hwnd, "open", strFilePath, "", "", lngShowCmd)

bimShellOpenFile = r

End Function

Open in new window

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.


Author Closing Comment

ID: 39713359
Thanks for the help - end result was:

Function OpenImage(sFilePathAndName As String)
       On Error GoTo Error_Handler

       Shell Chr(34) & "C:\Windows\System32\mspaint.exe" & Chr(34) & " " & Chr(34) & sFilePathAndName & Chr(34), 1

       If Err.Number = 0 Then Exit Function

    MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf & "Error Number: " & Err.Number & vbCrLf & "Error Source: OpenImage" & vbCrLf & "Error Description: " & Err.Description, vbCritical, "An Error has Occured!"
   Exit Function
End Function
LVL 21
ID: 39714454
Thanks for the update and points.

I would also add a test to see if the file exists before executing the Shell().

Function OpenImage(sFilePathAndName As String)
       On Error GoTo Error_Handler

       ' Test to be sure the file exists before opening
       If Len(Dir(sFilePathAndName )) < 0 then 
            MsgBox "File not found!"
            Exit Function
       End If

       Shell Chr(34) & "C:\Windows\System32\mspaint.exe" & Chr(34) & " " & Chr(34) & sFilePathAndName & Chr(34), 1

       If Err.Number = 0 Then Exit Function

    MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf & "Error Number: " & Err.Number & vbCrLf & "Error Source: OpenImage" & vbCrLf & "Error Description: " & Err.Description, vbCritical, "An Error has Occured!"
   Exit Function
End Function 

Open in new window


Author Comment

ID: 39715087

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
My experience with Windows 10 over a one year period and suggestions for smooth operation
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

919 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

18 Experts available now in Live!

Get 1:1 Help Now