Hi ,
i have some code to import Excel Spread sheet to a table call tblExcelimport i then add just the file name to tblexcelfilename
here the code probably could be neater or better lol
now what i'm trying to do is check if the user selects a file and the file name is already in tblexcelfilename to have message to say excel file already imported then exit sub
cheers
thanks in advance
shane
i have some code to import Excel Spread sheet to a table call tblExcelimport i then add just the file name to tblexcelfilename
here the code probably could be neater or better lol
Code:
Dim SelectedFile As String
Dim FilePicker As FileDialog
Dim SQLdelete As String
Set FilePicker = Application.FileDialog(msoFileDialogFilePicker)
FilePicker.AllowMultiSelect = False
FilePicker.Filters.Add "Excel", "*.xls*", 1
FilePicker.InitialFileName = "C:\Users\"
FilePicker.Title = "Please Select the Excel Data..."
FilePicker.Show
If FilePicker.SelectedItems.Count <> 0 Then
SelectedFile = FilePicker.SelectedItems(1)
'DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "test1", SelectedFile, True
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblExcelImport", SelectedFile, True, "A4:E"
Set rs = CurrentDb.OpenRecordset("ExcelFileName")
rs.AddNew
rs.Fields("Pathname").Value = Right([SelectedFile], Len([SelectedFile]) - InStrRev([SelectedFile], "\"))
rs.Update
rs.Close
Set rs = Nothing
MsgBox ("The data has been successfully loaded")
End If
End Sub
now what i'm trying to do is check if the user selects a file and the file name is already in tblexcelfilename to have message to say excel file already imported then exit sub
cheers
thanks in advance
shane