Access 2007中出现-3087错误

时间:2013-11-18 21:18:00

标签: sql ms-access ms-access-2007

我有以下代码:

SELECT
    Count(personnel.Position) AS countofposition,
    personnel.Position, 
    Year(DateAdd("m",-6,[Personnel.End_Date])) & "-"
        & Year(DateAdd("m",6,[Personnel.End_Date]))
FROM personnel 
GROUP BY Year(DateAdd("m",-6,[Personnel.End_Date])) & "-"
    & Year(DateAdd("m",6,[Personnel.End_Date]));

我收到“保留错误(-3087);此错误没有消息”消息

我查看了保留字的列表,我很确定我没有使用任何字。我唯一可以想到的是,“年(DateAdd ...... blahblahblahblahblah)”中的“年”让我感到困扰

编辑:此外,personnel.position是一个多值字段 想法?

1 个答案:

答案 0 :(得分:1)

我认为这就是你要找的东西:

对于具有多值字段[位置]的表[人员]:

ID  FirstName  LastName  Position        End_Date
--  ---------  --------  --------------  ----------
1   Gord       Thompson  CTO, President  2013-11-01
2   Anne       Elk       Vice-President  2013-11-01
3   P. T.      Gumby     Vice-President  2013-11-01

查询

SELECT 
    Count(Personnel.Position.Value) AS CountOfPosition_Value, 
    Personnel.Position.Value, 
    Year(DateAdd("m",-6,[Personnel.End_Date])) & "-" & Year(DateAdd("m",6,[Personnel.End_Date])) AS Expr1
FROM Personnel
GROUP BY 
    Personnel.Position.Value, 
    Year(DateAdd("m",-6,[Personnel.End_Date])) & "-" & Year(DateAdd("m",6,[Personnel.End_Date]));

返回

CountOfPosition_Value  Personnel.Position.Value  Expr1    
---------------------  ------------------------  ---------
                    1  CTO                       2013-2014
                    1  President                 2013-2014
                    2  Vice-President            2013-2014