Private Sub Command16_Click()
On Error GoTo ErrorHandler
Dim dlgOpen As Office.FileDialog
Dim InitialFileName As String
Dim SelectFile As String
Dim strFileNameAndPath As String
Dim varSelectedItem As Variant
Dim MyPath As String
Set dlgOpen = Application.FileDialog(msoFileDialogFilePicker)
With dlgOpen
.Title = "Select a phone list"
.AllowMultiSelect = False
.Filters.Add "CSV Files Only", "*.csv", 1
.InitialFileName = "C:\"
.InitialView = msoFileDialogViewDetails
If .Show = -1 Then strFileNameAndPath = .SelectedItems(1)
End With
Me.txtFPath = strFileNameAndPath
MyPath = Me.txtFPath
DoCmd.SetWarnings False
DoCmd.TransferText acImportDelim, "PhoneList Import Specification", "tblPhtemp", MyPath
MsgBox ("Finished importing Phone List")
DoCmd.SetWarnings True
Me.Form.Requery
ErrorHandlerExit:
Set dlgOpen = Nothing
Exit Sub
ErrorHandler:
If Err.Number = 2522 Then
Exit Sub
End If
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End Sub
|