Hello, I am stumped. I have a code that has been working without issues. Doing QC, I am running into error 3251. I have reviewed the spreadsheets from excel and do not see anything different. What is bizzar, this code works fine for the other imports/buttons. I have done compact and repair, debug, created new form new button and same code, and moved all into another DB for possible corruption. Weird. Any suggestions?
Code:
Option Compare Database
Option Explicit
Private Sub Command0_Click()
Dim FilePicker As FileDialog
Dim intLine As Long
Dim SelectedFile As String
Dim dbs As DAO.Database
Dim vrtSelectedItem As Variant
Set dbs = CurrentDb
Set FilePicker = Application.FileDialog(msoFileDialogFilePicker)
On Error GoTo Err_Display
CurrentDb.Execute "DELETE * FROM tblImportHR_CC", dbFailOnError '
CurrentDb.Execute "DELETE * FROM tblAppImportHR_CC", dbFailOnError '
FilePicker.AllowMultiSelect = True
FilePicker.Filters.Add "Excel", "*.xls*", 1
FilePicker.InitialFileName = "C:\Users\"
FilePicker.Title = "Please Select the Excel Data..."
If FilePicker.Show = -1 Then
For Each vrtSelectedItem In FilePicker.SelectedItems
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblImportHR_CC", vrtSelectedItem, True, "L:P"
Application.FollowHyperlink vrtSelectedItem
Next
DoCmd.OpenForm "frmImportHR_CC", acViewNormal, acEdit
MsgBox ("The data has been successfully loaded")
Else
Call MsgBox("No file was selected.")
End If
Err_Exit:
Exit Sub
Err_Display:
MsgBox "An error has occurred. Please review the workbook you have selected. The most common error(s) is/are you choose the wrong workbook or there is/are extra data cells not recognized. Otherwise, please check error " & Err.Number & " " & Err.Description
Resume Err_Exit
End Sub