Results 1 to 3 of 3
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672

    File Picker To Only Allow Single File Section

    This syntax works, but it allows for multiple file selection, is there a way to alter it so that you can only select one file, and a notification will be displayed if you attempt to select more than 1 file?
    Code:
        Set f = Application.FileDialog(3)
    
    
        With f
            .AllowMultiSelect = False
            .Title = "Please Select the Excel File To Import"
            .Filters.Add "Excel Files", "*.xlsx"
    
    
            If .Show = True Then
                For i = 1 To f.SelectedItems.Count
                    selectedfile = f.SelectedItems(i)                
                    DoCmd.TransferSpreadsheet acImport, param, "AccessTableName", selectedfile, True
                Next i
    			
    		End If
    	End With


  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,423
    your .AllowMultiSelect = False should stop the users being able to select more than one file - so far as I am aware there is no way filedialog can be set to generate such an error but you can in vba modify your code

    Code:
    If .Show = True Then
        if f.SelectedItems.Count>1 then
            msgbox "only one item to be selected"
        else
           selectedfile = f.SelectedItems(1)                
           DoCmd.TransferSpreadsheet acImport, param, "AccessTableName", selectedfile, True
        end if
          
     	End If
    	End With

  3. #3
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Thanks for the tip on that.

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

Similar Threads

  1. Replies: 7
    Last Post: 11-20-2012, 05:08 PM
  2. Replies: 13
    Last Post: 11-07-2012, 03:14 PM
  3. Replies: 3
    Last Post: 07-30-2012, 02:16 PM
  4. VBA - file picker
    By riteoh in forum Programming
    Replies: 1
    Last Post: 10-12-2010, 06:30 AM
  5. bypass file picker?
    By techneophyte in forum Programming
    Replies: 6
    Last Post: 08-17-2010, 11:12 AM

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