Attach the following event procedure to the On Click event of a button called 'Import_File'.
Private Sub Import_File_Click()
On Error GoTo Err_Import_File_Click
Dim strFile_Path As String
Dim strTable As String
'Prompt user for file path
strFile_Path = InputBox("Please enter file path")
'Prompt user for name of table to create for imported data
strTable = InputBox("Please enter name of new table")
'Import file, using inputted file path and table name
DoCmd.TransferText acImportDelim, , strTable, strFile_Path
Exit_Import_File_Click:
Exit Sub
Err_Import_File_Click:
If Err.Number = 3011 Then
MsgBox strFile_Path & " is not a valid path, please try again", vbExclamation, "Invalid File Path"
Else
MsgBox Err.Description
End If
Resume Exit_Import_File_Click
End Sub