UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Selecting Multiple Files Using A Dialog Box And Pasting The URL And Filenames, Access 2016    
 
   
M2C
post Jun 13 2018, 03:18 AM
Post#1



Posts: 638
Joined: 7-April 08
From: Dubai


Hi I am opening a multiselect dialog box to select multiple files in a folder.
CODE
    Dim lngCount As Long

    ' Open the file dialog
    With Application.FileDialog(msoFileDialogOpen)
        .AllowMultiSelect = True
        .Show

        ' Display paths of each file selected
        For lngCount = 1 To .SelectedItems.Count
            MsgBox .SelectedItems(lngCount)
        Next lngCount

    End With

This works fine, however once I have selected one or more files I would like to paste their URLs and their filenames into the field Forms!FrmDoc!DocURL when I close the dialog box.

Any ideas how I can do this?
Thanks
Chris

--------------------
Chris
Go to the top of the page
 
M2C
post Jun 13 2018, 05:31 AM
Post#2



Posts: 638
Joined: 7-April 08
From: Dubai


Sorry girls and boys and I knew that I had the same problem many moons ago and theDBGuy came to my rescue

Here is the solution:

CODE
'Modified by theDBguy@gmail.com
'2/5/2014
Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("tmpDoc", dbOpenDynaset)

' This requires a reference to the Microsoft Office 11.0 Object Library.

   Dim fDialog As Office.FileDialog
   Dim varFile As Variant

   ' Set up the File dialog box.
   Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
   With fDialog
      ' Allow the user to make multiple selections in the dialog box.
      .AllowMultiSelect = True
            
      ' Set the title of the dialog box.
      .Title = "Select One or More Files"

      ' Clear out the current filters, and then add your own.
      .Filters.Clear
      '.Filters.Add "Access Databases", "*.MDB"
      '.Filters.Add "Access Projects", "*.ADP"
      .Filters.Add "All Files", "*.*"

      ' Show the dialog box. If the .Show method returns True, the
      ' user picked at least one file. If the .Show method returns
      ' False, the user clicked Cancel.
      If .Show = True Then
         ' Loop through each file that is selected and then add it to the list box.
         For Each varFile In .SelectedItems
            With rs
                .AddNew
                    !DocURL = varFile
                .Update
            End With
            Me.Requery
         Next
      Else
         MsgBox "You clicked Cancel in the file dialog box."
      End If
   End With

'Cleanup
rs.Close
Set rs = Nothing
Set db = Nothing

--------------------
Chris
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    14th August 2018 - 10:21 AM