Results 1 to 7 of 7
  1. #1
    AccessSHELL is online now Advanced Beginner
    Windows 10 Access 2003
    Join Date
    Jul 2020
    Location
    U.S.
    Posts
    49

    Question Using pictures


    I am using MS Access 2003 on WIN10. Can I place a picture in a table? If so, how?

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    2003 might have OLEObject type field which can store objects. But I think this will really complicate dynamic display of images.

    I think Attachment data type introduced with Access 2007.
    Advise upgrade to accdb format so can have use of Image control that has ControlSource property.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    and I would advise to store the images on a server, and put the PATH to them in the table.
    This keeps the database from growing too large and hitting the limit of 2 gig.

    field [ImageName]: \\server\folder\photo1.jpg


    Paste this code into a module, and it will open ANY file in its native application.
    In a form put the field and a button to open it.


    if the file is myFile.pdf, will open it in acrobat
    if the file is myFile.doc, it will open the doc in Word
    if its just a file path, it will open in file explorer.
    etc..


    usage:
    OpenNativeApp txtBox


    paste this code into a module
    Code:
    'Attribute VB_Name = "modNativeApp"
    'Option Compare Database
    Option Explicit
    
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
    
    
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Const SW_SHOWNORMAL = 1
    Const SE_ERR_FNF = 2&
    Const SE_ERR_PNF = 3&
    Const SE_ERR_ACCESSDENIED = 5&
    Const SE_ERR_OOM = 8&
    Const SE_ERR_DLLNOTFOUND = 32&
    Const SE_ERR_SHARE = 26&
    Const SE_ERR_ASSOCINCOMPLETE = 27&
    Const SE_ERR_DDETIMEOUT = 28&
    Const SE_ERR_DDEFAIL = 29&
    Const SE_ERR_DDEBUSY = 30&
    Const SE_ERR_NOASSOC = 31&
    Const ERROR_BAD_FORMAT = 11&
    
    
    
    
    Public Sub OpenNativeApp(ByVal psDocName As String)
    Dim r As Long, msg As String
    
    
    r = StartDoc(psDocName)
    If r <= 32 Then
        'There was an error
        Select Case r
            Case SE_ERR_FNF
                msg = "File not found"
            Case SE_ERR_PNF
                msg = "Path not found"
            Case SE_ERR_ACCESSDENIED
                msg = "Access denied"
            Case SE_ERR_OOM
                msg = "Out of memory"
            Case SE_ERR_DLLNOTFOUND
                msg = "DLL not found"
            Case SE_ERR_SHARE
                msg = "A sharing violation occurred"
            Case SE_ERR_ASSOCINCOMPLETE
                msg = "Incomplete or invalid file association"
            Case SE_ERR_DDETIMEOUT
                msg = "DDE Time out"
            Case SE_ERR_DDEFAIL
                msg = "DDE transaction failed"
            Case SE_ERR_DDEBUSY
                msg = "DDE busy"
            Case SE_ERR_NOASSOC
                msg = "No association for file extension"
            Case ERROR_BAD_FORMAT
                msg = "Invalid EXE file or error in EXE image"
            Case Else
                msg = "Unknown error"
        End Select
    '    MsgBox msg
    End If
    End Sub
    
    
    
    
    Private Function StartDoc(psDocName As String) As Long
    Dim Scr_hDC As Long
    
    
    Scr_hDC = GetDesktopWindow()
    StartDoc = ShellExecute(Scr_hDC, "Open", psDocName, "", "C:\", SW_SHOWNORMAL)
    End Function



    usage:


    Code:
    sub btnOpenFile_click()
      OpenNativeApp ME.txtBox
    end sub

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    AccessSHELL,

    You may also find some useful info in the Similar Threads area at the bottom of the page.

  5. #5
    AccessSHELL is online now Advanced Beginner
    Windows 10 Access 2003
    Join Date
    Jul 2020
    Location
    U.S.
    Posts
    49
    Thanks. I will not place the pics in the DB. I will place a path and filename in the DB.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    If you stick with Access 2003, dynamically displaying images in a report will require VBA code setting Picture property of Image control. Update to accdb format and can use ControlSource property without VBA.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    AccessSHELL is online now Advanced Beginner
    Windows 10 Access 2003
    Join Date
    Jul 2020
    Location
    U.S.
    Posts
    49
    I prefer to write my code in VB6. I use MS Access or MS Excel where appropriate to sore information. I write only for me, as I am retired. I do not wish to upgrade to a newer version of Access or Excel.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using Pictures
    By UT227 in forum Misc
    Replies: 12
    Last Post: 08-12-2019, 05:20 PM
  2. Pictures
    By Michael73052 in forum Forms
    Replies: 1
    Last Post: 08-12-2012, 01:08 PM
  3. Do not repeat pictures
    By gabrielharo in forum Forms
    Replies: 1
    Last Post: 06-12-2012, 04:58 PM
  4. Working with pictures
    By JFo in forum Access
    Replies: 9
    Last Post: 02-28-2012, 11:01 PM
  5. Linking pictures
    By cowboy in forum Access
    Replies: 4
    Last Post: 02-15-2010, 05:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums