VBA过程返回结果只有一个特定的date

大家。 我有一个程序,每天从大表中提取某些数据,然后将这些数据粘贴到一个excel文件中。 源表包含约200万条logging(从2015年10月1日至2016年9月9日),并以每月22万条logging的速度增长。 下面的程序提取了我所需要的数据,直到2016年6月中旬。从那时起,它不能提取任何数据。 运行常规查询确实显示数据在那里。 打开表格也显示了相同的结果 – 数据截至09.09.2016)。 我会认为代码有一些其他问题,但它在另一个表上正常工作。 它也适用于这一个,但不能想到为什么它不会find2016年6月中旬以前的logging。我索引date字段,这是我提取logging的参数,但没有帮助。 任何帮助和build议,高度赞赏。 谢谢你的时间。 这是我的代码:

Dim xl As Excel.Application Dim wb As Excel.Workbook Dim xs As Excel.Worksheet Dim rng As Excel.Range Dim c_range As Excel.Range Dim dbs As DAO.Database Dim qdf As DAO.QueryDef Dim rst As DAO.Recordset Dim strsql As String strsql = "SELECT tblTraderExecutions.exec_id, tblTraderExecutions.exec_date, tblTraderExecutions.exec_time, tblTraderExecutions.empty, tblTraderExecutions.exec_string, tblTraderExecutions.internal_order_id, tblTraderExecutions.trading_account, " & _ "tblTraderExecutions.trading_account, tblTraderExecutions.operation_bg, tblTraderExecutions.empty, tblTraderExecutions.empty, tblTraderExecutions.symbol, tblTraderExecutions.symbol, tblTraderExecutions.price, tblTraderExecutions.quantity, " & _ "tblTraderExecutions.currency, ROUND(tblTraderExecutions.total_comm,2), tblTraderExecutions.empty, Round((tblTraderExecutions.quantity * tblTraderExecutions.price),2), Round((tblTraderExecutions.quantity * tblTraderExecutions.price),2), " & _ "tblTraderExecutions.trade_broker, tblTraderExecutions.contra, tblTraderExecutions.accept_broker FROM tblTraderExecutions " & _ "WHERE [exec_date] = [start_date] ORDER BY [tblTraderExecutions].[exec_id]" Set dbs = CurrentDb Set qdf = dbs.CreateQueryDef(vbNullString, strsql) qdf.Parameters("start_date").Value = Forms!frmPropReports!txtDate Set rst = qdf.OpenRecordset Set xl = New Excel.Application xl.Visible = True Set wb = xl.Workbooks.Open("D:\mpuls\trader_executions_export.xlsx") Set ws = wb.Worksheets("DNEVNICI") Set rng = ws.Range("a8") rng.CopyFromRecordset rst Set c_range = ws.Range("c8:c65000") c_range.NumberFormat = "h:mm:ss;@" rst.Close qdf.Close Set qdf = Nothing Set rst = Nothing Set dbs = Nothing 

首先我要感谢所有贡献的人。 我的数据库是在Access 2016上创build的,而且我在另一台电脑上使用Access 2013运行它。这是它将logging仅返回到某个特定date的地方。 使用Access 2016将其移动到一台电脑后,它按预期工作,但只在后台运行excel,导出的文件中包含所有适用的logging。 在这一点上,我把行xl.Visible = true的行放在xl.workbooks.open行的下面。 这就像一个魅力。