SQL query in Access error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hawaiijeff
    New Member
    • Oct 2007
    • 22

    SQL query in Access error

    I have a database in Access 2003 that is attempting to insert rows from table A into table B. One of the columns in table B is a date, which is derived by taking the minimum date from table A and using that to populate every row that is inserted into table B at this time. The insert query in SQL is below:

    Code:
    [I]INSERT INTO tblSUPERVISOR_SUMMARY (WEEK, SUPERVISOR, other stuff)
    SELECT (select min([ACTUAL DATE IN]) from krtimecsv) AS Expr1, tblPIVOT_OVT.SUPERVISOR, other stuff
    FROM  tblPIVOT_OVT RIGHT JOIN tblSUM_HOURS_ALL_PAY_CODE ON tblPIVOT_OVT.[EMPLOYEE NUMBER] = tblSUM_HOURS_ALL_PAY_CODE.[EMPLOYEE NUMBER]
    GROUP BY (select min([ACTUAL DATE IN]) from krtimecsv), tblPIVOT_OVT.SUPERVISOR;[/I]
    when I hit the button to see the results in datasheet view or try to execute the query I get this error:

    'Syntax error. in query expression '(select min([ACTUAL DATE IN]) from krtimecsv)'.

    The thing that is oddest about this is that I have this particular query called from a macro that gets run every week. And it appears that it ran without error based on the fact that it actually populated the table with the desired data on it's own. Is there any reason why it would error out now, but not in a macro? Does anyone know of a better way to accomplish this that maybe wouldn't cause a problem? Thanks.
  • hawaiijeff
    New Member
    • Oct 2007
    • 22

    #2
    It always seems that you ask everyone about a problem and get no response, and then the second you post it online somebody tells you the answer. Apparently this query is not being used in the macro, as I thought it was, the code was imbedded into the macro, which explains why the table is being updated correctly.

    Comment

    Working...