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    
post Jun 13 2018, 03:18 AM

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

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

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

        ' 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?
Go to the top of the page
post Jun 13 2018, 05:31 AM

Posts: 664
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:

'Modified by theDBguy@gmail.com
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.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
                    !DocURL = varFile
            End With
         MsgBox "You clicked Cancel in the file dialog box."
      End If
   End With

Set rs = Nothing
Set db = Nothing
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    25th May 2019 - 10:24 PM