我正在运行某种错误SAYING这个表达式键入不正确,或者它太复杂而无法评估

时间:2016-06-13 15:57:52

标签: ms-access

keyup

1 个答案:

答案 0 :(得分:0)

试试这个:

SELECT T.NAME AS Expr1, T.AREA AS Expr2, T.AlarmCount,
  Format([T].[ITIME],"General Date") AS ITIME,
  Format(T.ATIME,"General Date") AS ATIME,
  Format(T.NTIME,"General Date") AS NTIME,
  T.DURATION AS Expr3
FROM (SELECT  DISTINCT(IWTUSER_ALARMS.NAME) AS NAME, 
          COUNT(*) AS AlarmCount,
          IWTUSER_ALARMS.AREA AS AREA, 
          IWTUSER_ALARMS.ITIME AS ITIME, 
          IWTUSER_ALARMS.ATIME AS ATIME, 
          IWTUSER_ALARMS.NTIME AS NTIME,
          IWTUSER_ALARMS.DUR AS DURATION
 FROM IWTUSER_ALARMS
 GROUP BY IWTUSER_ALARMS.NAME, 
                  IWTUSER_ALARMS.AREA, 
                ITIME,                  
                ATIME, 
                NTIME, 
                IWTUSER_ALARMS.DUR
)  AS T
WHERE (((T.ITIME)>=Date()-180));

错误是由您的WHERE子句引起的。 ITIME已经是一个日期,因此您可以比较它而不需要格式化为字符串(格式表达式错误),然后还原为日期无效的日期,ITIME来自临时表T IWTUSER_ALARMS条款中没有WHERE

IWTUSER_ALARMS.DUR AS DURATION有别名DURATION

您的日期格式错误。试试Debug.Print Format(#6/18/2016#,"0000-00-00 00\:00\:00 ")。这是格式化日期http://www.techonthenet.com/access/functions/date/format.php的方式。

ITIMES, ATIME and NTIME应显示为字符串,我假设或删除格式(请参阅WHERE子句错误)。

避免在变量和标识符中使用NAME之类的保留关键字。希望我抓住他们所有人!