Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
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
Public Sub DisplayUnexpectedError(ErrorNumber As String, ErrorDescription As String) Select Case Err.Number Case 2522 MsgBox "You did not select an Excel file" End Select End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.