Link to home
Start Free TrialLog in
Avatar of Donald Whittemore
Donald WhittemoreFlag for United States of America

asked on

Insert SQL data into Access

User generated imageI have an empty Access table.  I need to select data from a SQL DB and insert into the Access table.  I eventually will do this using VBA but for now I am just trying to get the major steps working.
The Access table is defined. Named TSHrs. Contains 3 fields (TSEmpID, TSHrs, TSDate)
I am doing a Pass-Through query
The ODBC connection is defined.
The query is:
Insert into TSHrs ([TSEmpID], [TSHrs], [TSDate])
Select EmployeeID as [EmpID]
,isnull(sum(HoursWorked),0) as [Hours]
,DatePart(Year,DateWorked)*100+Datepart(Month,DateWorked) AS [RptMonth]
from Hours
where DatePart(Year,DateWorked)*100+Datepart(Month,DateWorked)=201202
group by EmployeeID, DatePart(Year,DateWorked)*100+Datepart(Month,DateWorked)
order by EmployeeID

When I run the query in Access I get the pictured error.  It appears I am trying to reference TSHrs in the SQL DB the ODBC references.  Have I approached this wrong?
ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial