Solved

MS Access and self reference table

Posted on 2016-11-02
4
51 Views
Last Modified: 2016-11-03
I have a table of employees.  There is a employee supervisor column which points to the employee record of the supervisor.  So, the table references itself.  The table has a dept column.   if the dept of the supervisor changes, I want to change the dept for all employees that have that supervisor.   I would know how to do this using SQL server, but I can't get it to work using MS Access.
0
Comment
Question by:HLRosenberger
  • 2
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 41871031
try this query

UPDATE tblEmployees INNER JOIN tblEmployees AS tblEmployees_1 ON tblEmployees.Supervisor = tblEmployees_1.EmployeeID SET tblEmployees.Dept = [tblEmployees_1].[Dept]
WHERE (((tblEmployees_1.EmployeeID)=5));

you have to place the EmployeeID of the supervisor in the criteria
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 250 total points
ID: 41871187
In general:

UPDATE Employee As e INNER JOIN Employee As s ON e.SupervisorID = s.EmployeeID
SET e.Dept = s.Dept
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41871194
;-)
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41872024
Thanks!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question