|
Function run()
DoCmd.SetWarnings False
rep = Application.CurrentProject.Path & "\"
startdate = InputBox("输入销售开始日期(年-月-日)", "输入日期", DateValue(FormatDateTime(Now(), 2)) - 7)
enddate = InputBox("输入销售结束日期(年-月-日)", "输入日期", DateValue(FormatDateTime(Now(), 2)) - 1)
sdate = Format(startdate, "yyyy-mm-dd")
edate = Format(enddate, "yyyy-mm-dd")
sql_sales = "select storecode as store,itemcode,sum(salesqty) as qty,sum(netsales) as sales,sum(netcost) as cost into p_sales from dbo_ls_sales where salesdate between '2012-07-23' and '2012-07-29' and netsales <> 0 and itemcode not like '2*' group by storecode,itemcode"
DoCmd.RunSQL sql_sales
……
以上是部分代码,但是执行“DoCmd.RunSQL sql_sales”总提示“标准表达式数据类型不匹配”,基本可以断定是salesdate有问题,因为SQL中这个字段是日期型,然而在ACCESS中,无法提供想匹配的日期,像startdate,sdate或是手工输入日期都试了,全部没用,请求高手解惑
|
|