Michael
Michael

Reputation: 2657

MS Access Multi File Copy

The below is my code. Basically it prompts the user to select files and copies them to a destination. However, I set the AllowMultiSelect = True, but the code only ever copies the first file the user selected and ignores any others. What am I missing?

With fDialog

      ' Allow user to make multiple selections in dialog box '
      .AllowMultiSelect = True

      ' Set the title of the dialog box. '
      .Title = "Please select a Video"

      ' Clear out the current filters, and add our own.'
      .Filters.Clear
      .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

      ' This section takes the selected image and copy's it to the generated path'
      ' the string takes the file location, navigates to the image folder, uses the combo box selection to decide the file category, then uses the name from the filedialog to finish the path'

    FileCopy .SelectedItems(1), DLookup("Brand", "tmpDestFolders") & Dir(Trim(.SelectedItems.Item(1)))

     Else
      End If
    End With

Upvotes: 0

Views: 285

Answers (1)

nagarajannd
nagarajannd

Reputation: 715

Loop through all selected items.

For i = 1 to .SelectedItems.Count
    FileCopy .SelectedItems(i), DLookup("Brand", "tmpDestFolders") & Dir(Trim(.SelectedItems(i)))
Next

Upvotes: 4

Related Questions