Results 1 to 5 of 5
  1. #1
    Jeff Lance is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2021
    Posts
    8

    VBA Store File picker return back into the table

    I have VBA code that when you click a text box it opens a file picker to choose a file for a reference for a picture on the form.
    How do I paste that file location and file information back into the text box to be saved in the table?

    P returns the info that needs to be saved in the Text Box and saved in the Table.

    Private Sub Text26_Click()
    Dim f As Object
    Dim strFile As String
    Dim strFolder As String
    Dim varItem As Variant
    Dim P As String

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


    End If

    ' CurrentDb.Execute "Insert Into tblinfo (Line3) " & P
    Set f = Nothing
    'MsgBox (strFile)
    'MsgBox (strFolder)
    MsgBox (P)

    End Sub

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Easiest way is to have the textbox, Text26 bound to the table field which appears to be Line3.
    Then

    Code:
    End If
    me.text26=P
    ' CurrentDb.Execute "Insert Into tblinfo (Line3) " & P
    Set f = Nothing
    'MsgBox (strFile)
    'MsgBox (strFolder)
    MsgBox (P)
    
    End Sub
    

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Jeff Lance is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2021
    Posts
    8
    Welshgasman

    I am not sure I understand what you are asking me to do?

    Use the # where? I went to the links you provided sense your request was vague, I did not see anything that explained that I needed to use a # when posting code.

    Thank You!

    Jeff

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Quote Originally Posted by Jeff Lance View Post
    Welshgasman

    I am not sure I understand what you are asking me to do?

    Use the # where? I went to the links you provided sense your request was vague, I did not see anything that explained that I needed to use a # when posting code.

    Thank You!

    Jeff
    That is my signature.
    I was merely posting to let others know that the query had been crossposted in another forum, so they would be aware and not repeat the same advice and waste their time?
    If you reply to this post, you will see # in the toolbar along with a link icon, bold,italic etc.?
    If you use the # icon and paste your code, it will keep the indentation and look like the code @davegri posted in post #2 ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. File Picker To Only Allow Single File Section
    By jo15765 in forum Programming
    Replies: 2
    Last Post: 05-29-2017, 04:25 PM
  2. file picker dialog and docmd transfer database table
    By REBBROWN in forum Programming
    Replies: 3
    Last Post: 08-11-2014, 02:12 PM
  3. Replies: 7
    Last Post: 11-20-2012, 05:08 PM
  4. Replies: 3
    Last Post: 07-30-2012, 02:16 PM
  5. Replies: 1
    Last Post: 02-05-2009, 04:53 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