TransferSpreadsheet错过了~200条记录 - 访问VBA

时间:2015-08-05 16:28:33

标签: access-vba

我正在编写一个脚本来将两个查询导出到excel电子表格。从那里,我在另一个处理数据的工作簿中运行一个宏。一切正常,但最初导出的数据缺少记录(每次大约200个)。

我的代码:

Root.plist

qry_OpenKaizens(应该有79条记录,有71条):

'Step 1: Run qry_OpenKaizens and ouput data to OpenKaizens.xlsx
    myQueryName = "qry_OpenKaizens"
    myExportFileName = CurrentProject.Path & "\OpenKaizens.xlsx"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, myQueryName, myExportFileName, True
'Step 2: Rim qry_closed Kaizens and output data to ClosedKaizens.xlsx
    myQueryName = "qry_ClosedKaizens"
    myExportFileName = CurrentProject.Path & "\ClosedKaizens.xlsx"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, myQueryName, myExportFileName, True

qry_ClosedKaizens(应该有7514条记录,但有7239条):

SELECT KaizenData.TrackingNumber, KaizenData.KaizenLevel, KaizenData.Plant, KaizenData.Year1, KaizenData.[Tracking No], KaizenData.MainPillar, KaizenData.Area AS Dept, KaizenData.Team AS Area, KaizenData.[OP/STA] AS [Machine/Station], KaizenData.ProjectName AS [Project Name], KaizenData.IssueDescription AS [Description Phenomena], KaizenData.SolutionDescription AS [Solution Description], KaizenData.[Project Board], KaizenData.[Loss Category], KaizenData.[Loss Type], KaizenData.EnteredDate AS [Entered Date], KaizenData.StartingDate AS [Starting Date], KaizenData.EndDate AS [Completion Data], KaizenData.Notes, KaizenData.EstimatedSavings, KaizenData.EstimatedCost, KaizenData.BC, [EstimatedSavings]-[EstimatedCost] AS [Estimated Benefit], IIf([openstatus]=True,"Open") AS Status
FROM KaizenData
WHERE (((IIf([openstatus]=True,"Open")) Is Not Null)); 

1 个答案:

答案 0 :(得分:0)

似乎你的where语句出了问题,而不是导出事务。

如果iif语句不在您的选择行上且您的where语句只是评估已关闭或打开?

当closedstatus为null或为空或包含空白时会发生什么?