G
Grace
Hello, I am trying to import data from an excel
spreadsheet and then run an append query to add the data
to an existing table. When I run the code, it can't seem
to find the file. I am entering the path name correctly
(TrainerTimeTracking.xls)and the file does exist. I have
double checked the spelling of the filename.
Here is my code so far:
Function ImportTrainingData()
Dim dbPath As String
Dim gotTable As Boolean
gotTable = False
dbPath = InputBox("Enter Location of Spreadsheet"
+ "(drive:\path\)", "Location of Spreadsheet")
If dbPath <> "" Then
DoCmd.TransferSpreadsheet acImport,
acSpreadsheetTypeExcel97, "TrainerTimeTracking.xls", True
MsgBox "Spreadsheet has been imported...",
vbExclamation, "Import Data"
DoCmd.OpenQuery "AppendTimeTrackingData", acNormal, acEdit
MsgBox "Data has been added to Time Tracking Table...",
vbExclamation, "Data Added"
gotTable = True
If gotTable = False Then
MsgBox "No data was imported, please check your path...",
vbCritical, "Import Tables Fail"
ImportExcel = False
Else
MsgBox "Your data has been imported and updated
successfully...", vbExclamation, "Import Successful"
ImportExcel = True
End If
Else
MsgBox "Import has been canceled by user",
vbCritical, "Operation Canceled"
ImportExcel = False
End If
End Function
Your help is greatly appreciated.
Grace
spreadsheet and then run an append query to add the data
to an existing table. When I run the code, it can't seem
to find the file. I am entering the path name correctly
(TrainerTimeTracking.xls)and the file does exist. I have
double checked the spelling of the filename.
Here is my code so far:
Function ImportTrainingData()
Dim dbPath As String
Dim gotTable As Boolean
gotTable = False
dbPath = InputBox("Enter Location of Spreadsheet"
+ "(drive:\path\)", "Location of Spreadsheet")
If dbPath <> "" Then
DoCmd.TransferSpreadsheet acImport,
acSpreadsheetTypeExcel97, "TrainerTimeTracking.xls", True
MsgBox "Spreadsheet has been imported...",
vbExclamation, "Import Data"
DoCmd.OpenQuery "AppendTimeTrackingData", acNormal, acEdit
MsgBox "Data has been added to Time Tracking Table...",
vbExclamation, "Data Added"
gotTable = True
If gotTable = False Then
MsgBox "No data was imported, please check your path...",
vbCritical, "Import Tables Fail"
ImportExcel = False
Else
MsgBox "Your data has been imported and updated
successfully...", vbExclamation, "Import Successful"
ImportExcel = True
End If
Else
MsgBox "Import has been canceled by user",
vbCritical, "Operation Canceled"
ImportExcel = False
End If
End Function
Your help is greatly appreciated.
Grace