Stopping TransferSpreadsheet when there is no data.
Posted on 2004-03-24
I am producing a time recording system and need to import variable amounts of data from excel spreadsheets.
If there is no data in column B, I need it to move on to the next command.
column B is the only column that cannot be empty in the table. At present my database is importing the blank rows and then I'm using a query to delete the extra data, but this is messy.
Any ideas are welcome, the code I'm using at the moment is below.
' This populates the Time Breakdown form
DoCmd.TransferSpreadsheet acImport, 8, "Time Breakdown", strPath & strFile, True, "Main!B9:F50"
' This will delete all the blank rows
DoCmd.OpenQuery "Q_DeleteBlanks", acViewNormal, acEdit
' This should update the ID field in the "Time Breakdown" table
DoCmd.OpenQuery "Q_Timesheet", acNormal, acEdit
' This will delete the Error Table
DoCmd.DeleteObject acTable, "F50_ImportErrors"