Results 1 to 9 of 9
  1. #1
    hmoritz72 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2016
    Location
    Cincinnati, Ohio
    Posts
    3

    Choosing/saving file name to link picture for ImageBox

    I am struggling to do something that seems like it should be easy in Access 2010. I have an image box on my tracking form that displays an image of our job. I ONLY store the file path for the image in the database, not the actual image. If I physically type the file path (example: I:\Job Tracking\Job Pictures\2017 pic\pic20171010.jpg), the image shows like I want it to (perfect!!).



    My question is this: Is there a way to click on the text box, choose the file path (example: I:\Job Tracking\Job Pictures\2017 pic\pic20171010.jpg) and have it retain the file path in the text box (maybe a button that opens the file explorer)? Currently I have to copy and paste the file path from another window and I would love to have my users do it on their own easily from within the Access database. Again, I only want to store the file path name and not the actual image.

    I am open to suggestions and thanks for any help or words of wisdom!

  2. #2
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,788
    I read this four times and still can't figure out what is going to or from where. You can copy text from a textbox but what's the concern about retaining it? You're afraid users will delete it? Maybe you're asking if you can use a file dialog to navigate to the file and copy the path into a textbox?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Bulzie is online now VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    I created a text box called vTextBox on a form and put this in the Double Click event of the field. (Got code off net).

    Private Sub vTextBox_DblClick(Cancel As Integer)

    Dim f As Object
    Dim strFile As String
    Dim strFolder As String
    Dim varItem As Variant

    Set f = Application.FileDialog(3)
    f.AllowMultiSelect = True
    If f.Show Then
    For Each varItem In f.SelectedItems
    strFile = Dir(varItem)
    strFolder = Left(varItem, Len(varItem) - Len(strFile))
    Me.vTextBox = strFolder & strFile

    ' MsgBox "Folder: " & strFolder & vbCrLf & _
    ' "File: " & strFile
    Next
    End If
    Set f = Nothing

    End Sub

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Tons of examples out there.

    This works to select only the folder path:

    Code:
    Dim f As FileDialog
    Set f = Application.FileDialog(msoFileDialogFolderPicker)
    f.AllowMultiSelect = False
    f.InitialFileName = "some folder path"
    If f.Show Then
        Me.Text69 = f.SelectedItems(1)
    End If
    Set f = Nothing
    And this for the path/filename:
    Code:
    Dim f As FileDialog
    Set f = Application.FileDialog(msoFileDialogFilePicker)
    f.AllowMultiSelect = False
    f.InitialFileName = "some folder path"
    f.Filters.Clear
    f.Filters.Add "Images", "*.gif; *.jpg; *.jpeg", 1
    If f.Show Then
        Me.Text69 = f.SelectedItems(1)
    End If
    Set f = Nothing
    Can be in button Click event or even textbox DoubleClick.
    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.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,788
    Unless you're sure of what the question really is, don't get too far into this just because I surmised that a dialog is what was needed. Might be best to wait for a response from OP.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    OP did ask: "maybe a button that opens the file explorer".
    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
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,788
    Best that I turn the lights on

  8. #8
    hmoritz72 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2016
    Location
    Cincinnati, Ohio
    Posts
    3
    I am sorry - I've been on cold medicine for a bit... Yes, to clarify, I need a button that opens file explorer but when I choose the file, I want the full path to be copied into a field on that form. If this doesn't make sense, I can try again. I just want it to be easy for the user to insert the full file path so we don't have to store the actual image.

    Thanks for everything! Sorry about the confusion...fighting pneumonia while programming is not a good combination.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Have you tried any of the suggested code? Issue resolved?
    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.

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

Similar Threads

  1. Replies: 8
    Last Post: 08-12-2016, 10:59 AM
  2. Replies: 3
    Last Post: 08-15-2012, 04:15 PM
  3. Saving Picture Example
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-27-2010, 07:05 PM
  4. Save imagebox to file?
    By EmSox in forum Forms
    Replies: 0
    Last Post: 07-28-2010, 10:32 AM
  5. Link form to picture & pdf files
    By rayhawk in forum Access
    Replies: 2
    Last Post: 06-24-2010, 08:54 AM

Tags for this Thread

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