Private Sub Command1_Click()
On Error GoTo Error_Handler
Dim fdg As FileDialog, vrtSelectedItem As Variant
Dim strSelectedFile As String
Set fdg = Application.FileDialog(msoFileDialogFilePicker)
With fdg
.AllowMultiSelect = False
.InitialView = msoFileDialogViewDetails
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
strSelectedFile = vrtSelectedItem
Next vrtSelectedItem
Else
End If
Dim StrSQL As String
StrSQL = "Delete * from Scrap;"
DoCmd.SetWarnings False
DoCmd.RunSQL StrSQL
DoCmd.SetWarnings True
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "Scrap", strSelectedFile, True, , False
End With
Set fd = Nothing
Exit_Procedure:
Exit Sub
Error_Handler:
DisplayUnexpectedError Err.Number, Err.Description
End Sub
|