billHassall
Registered User.
- Local time
- Today, 04:14
- Joined
- Feb 25, 2010
- Messages
- 27
I have a function that deletes existing data in tables, imports new data nad then exports queries into the same excel file. I have three different functions that are very similar, two of them run perfectly, the third comes back with an error message "too many fields defined". I have tried to compact and repair the database, I have tried to import everything out of the existing database into a new one, I have deleted and rebuild the query that is causing the problem and none of these have worked. The query itself if you just open it will run OK, it is only when I am trying to export the query that I have this problem. I have included the code that I am using, any help would be appreciated, I have highlighted in red the query that will not export
'------------------------------------------------------------
' Day 2 results
'
'------------------------------------------------------------
Function Day_2_Results()
On Error GoTo Monthly_Clears_Err
DoCmd.SetWarnings False
' Run Delete query Daily data
DoCmd.OpenQuery "Delete Daily Data", acViewNormal, acEdit
' Close query Delete Daily Data
DoCmd.Close acQuery, "Delete Daily Data"
' Run Delete PSPD Data
DoCmd.OpenQuery "Delete PSPD Data", acViewNormal, acEdit
' Close query Delete PSPD Data
DoCmd.Close acQuery, "Delete PSPD Data"
MyPath = CurrentProject.Path
DoCmd.SetWarnings False
' Import Daily Data.csv
DoCmd.TransferText acImportDelim, "Daily Data Import Specification", "Daily data", MyPath & "\Daily Data.csv", True, ""
' Import PSPD Data.csv
DoCmd.TransferText acImportDelim, "DCR Last Month Import Specification", "PSPD Data", MyPath & "\DCR Last Month.csv", True, ""
' Run all of the queries
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "11 Monthly Day 2 9R", MyPath & "\Day 2 Delivery.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "11 Monthly Day 2 5R", MyPath & "\Day 2 Delivery.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "0 PARBD L2C Estimates", MyPath & "\Day 2 Delivery.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "0 PARBD T2R Estimates", MyPath & "\Day 2 Delivery.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "0 PSPD Failure", MyPath & "\Day 2 Delivery.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "073 LLIB > 90 days Failures", MyPath & "\Day 2 Delivery.xls", True
Beep
MsgBox "Import Has finished, data exported to Day 2 Delivery.XLS", vbOKOnly, "Messag"
Monthly_Clears_Exit:
Exit Function
Monthly_Clears_Err:
MsgBox Error$
Resume Monthly_Clears_Exit
End Function
'------------------------------------------------------------
' Day 2 results
'
'------------------------------------------------------------
Function Day_2_Results()
On Error GoTo Monthly_Clears_Err
DoCmd.SetWarnings False
' Run Delete query Daily data
DoCmd.OpenQuery "Delete Daily Data", acViewNormal, acEdit
' Close query Delete Daily Data
DoCmd.Close acQuery, "Delete Daily Data"
' Run Delete PSPD Data
DoCmd.OpenQuery "Delete PSPD Data", acViewNormal, acEdit
' Close query Delete PSPD Data
DoCmd.Close acQuery, "Delete PSPD Data"
MyPath = CurrentProject.Path
DoCmd.SetWarnings False
' Import Daily Data.csv
DoCmd.TransferText acImportDelim, "Daily Data Import Specification", "Daily data", MyPath & "\Daily Data.csv", True, ""
' Import PSPD Data.csv
DoCmd.TransferText acImportDelim, "DCR Last Month Import Specification", "PSPD Data", MyPath & "\DCR Last Month.csv", True, ""
' Run all of the queries
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "11 Monthly Day 2 9R", MyPath & "\Day 2 Delivery.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "11 Monthly Day 2 5R", MyPath & "\Day 2 Delivery.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "0 PARBD L2C Estimates", MyPath & "\Day 2 Delivery.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "0 PARBD T2R Estimates", MyPath & "\Day 2 Delivery.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "0 PSPD Failure", MyPath & "\Day 2 Delivery.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "073 LLIB > 90 days Failures", MyPath & "\Day 2 Delivery.xls", True
Beep
MsgBox "Import Has finished, data exported to Day 2 Delivery.XLS", vbOKOnly, "Messag"
Monthly_Clears_Exit:
Exit Function
Monthly_Clears_Err:
MsgBox Error$
Resume Monthly_Clears_Exit
End Function