All
Below is what I am trying to do.
I need to update a table (Table A) with data from another table (Table B) but only update the first row or 1 row of each grouping of rows.
Table A
IDNmbr Empl_Numb PEREND Names PayType Visits
1 10047 9/16/2016 JohnDoe REGULAR
2 10047 9/16/2016 JohnDoe Vacation
3 10047 9/16/2016 JohnDoe PTO
4 10047 9/23/2016 JohnDoe REGULAR
5 10047 9/23/2016 JohnDoe HOLIDAY
6 10047 9/23/2016 JohnDoe SICK
7 10099 9/16/2016 ZachYork Vacation
8 10099 9/16/2016 ZachYork PTO
9 10200 9/16/2016 JessTill Vacation
10 10200 6/23/2016 JessTill PTO
11 10200 9/23/2016 JessTill TRAVEL
12 10500 9/16/2016 PaulDown REGULAR
Table B
empl_no emp_name Visits PEREND
10047 JohnDoe 13 9/16/2016
10075 RobBate 20 9/16/2016
10020 JackFlash 29 9/16/2016
10099 ZachYork 24 9/16/2016
10200 JessTill 20 9/16/2016
10500 PaulDown 22 9/16/2016
10047 JohnDoe 25 9/23/2016
10200 JessTill 25 9/23/2016
Table A - What I need it to look like after update.
IDNmbr Empl_Numb PEREND Names PayType Visits
1 10047 9/16/2016 JohnDoe REGULAR 13
2 10047 9/16/2016 JohnDoe Vacation
3 10047 9/16/2016 JohnDoe PTO
4 10047 9/23/2016 JohnDoe REGULAR 25
5 10047 9/23/2016 JohnDoe HOLIDAY
6 10047 9/23/2016 JohnDoe SICK
7 10099 9/16/2016 ZachYork Vacation 24
8 10099 9/16/2016 ZachYork PTO
9 10200 9/16/2016 JessTill Vacation 20
10 10200 6/23/2016 JessTill PTO 25
11 10200 9/23/2016 JessTill TRAVEL
12 10500 9/16/2016 PaulDown REGULAR 22
What my table looks like AFTER MY QUERY... (Counting the visits too many times.)
IDNmbr Empl_Numb PEREND Names PayType Visits
1 10047 9/16/2016 JohnDoe REGULAR 13
2 10047 9/16/2016 JohnDoe Vacation 13
3 10047 9/16/2016 JohnDoe PTO 13
4 10047 9/23/2016 JohnDoe REGULAR 25
5 10047 9/23/2016 JohnDoe HOLIDAY 25
6 10047 9/23/2016 JohnDoe SICK 25
7 10099 9/16/2016 ZachYork Vacation 24
8 10099 9/16/2016 ZachYork PTO 24
9 10200 9/16/2016 JessTill Vacation 20
10 10200 6/23/2016 JessTill PTO 25
11 10200 9/23/2016 JessTill TRAVEL 25
12 10500 9/16/2016 PaulDown REGULAR 22
Current Query
UPDATE [TableA] INNER JOIN TableA ON ([TableB].empl_no = [TableA].Employee_no) AND ([TableB].PEREND = [TableA].[PEREND]) SET TableA = [TableB].Visits
WHERE [TableA].IDNmbr IN (SELECT Min(IDNmbr)
FROM TableA
GROUP BY Employee_no,PEREND);
Any help is GREATLY appreciated. If I only knew in ACCESS what I know how to do in Excel and Excel VBA.
Willing to LEARN!
Thank you
Below is what I am trying to do.
I need to update a table (Table A) with data from another table (Table B) but only update the first row or 1 row of each grouping of rows.
Table A
IDNmbr Empl_Numb PEREND Names PayType Visits
1 10047 9/16/2016 JohnDoe REGULAR
2 10047 9/16/2016 JohnDoe Vacation
3 10047 9/16/2016 JohnDoe PTO
4 10047 9/23/2016 JohnDoe REGULAR
5 10047 9/23/2016 JohnDoe HOLIDAY
6 10047 9/23/2016 JohnDoe SICK
7 10099 9/16/2016 ZachYork Vacation
8 10099 9/16/2016 ZachYork PTO
9 10200 9/16/2016 JessTill Vacation
10 10200 6/23/2016 JessTill PTO
11 10200 9/23/2016 JessTill TRAVEL
12 10500 9/16/2016 PaulDown REGULAR
Table B
empl_no emp_name Visits PEREND
10047 JohnDoe 13 9/16/2016
10075 RobBate 20 9/16/2016
10020 JackFlash 29 9/16/2016
10099 ZachYork 24 9/16/2016
10200 JessTill 20 9/16/2016
10500 PaulDown 22 9/16/2016
10047 JohnDoe 25 9/23/2016
10200 JessTill 25 9/23/2016
Table A - What I need it to look like after update.
IDNmbr Empl_Numb PEREND Names PayType Visits
1 10047 9/16/2016 JohnDoe REGULAR 13
2 10047 9/16/2016 JohnDoe Vacation
3 10047 9/16/2016 JohnDoe PTO
4 10047 9/23/2016 JohnDoe REGULAR 25
5 10047 9/23/2016 JohnDoe HOLIDAY
6 10047 9/23/2016 JohnDoe SICK
7 10099 9/16/2016 ZachYork Vacation 24
8 10099 9/16/2016 ZachYork PTO
9 10200 9/16/2016 JessTill Vacation 20
10 10200 6/23/2016 JessTill PTO 25
11 10200 9/23/2016 JessTill TRAVEL
12 10500 9/16/2016 PaulDown REGULAR 22
What my table looks like AFTER MY QUERY... (Counting the visits too many times.)
IDNmbr Empl_Numb PEREND Names PayType Visits
1 10047 9/16/2016 JohnDoe REGULAR 13
2 10047 9/16/2016 JohnDoe Vacation 13
3 10047 9/16/2016 JohnDoe PTO 13
4 10047 9/23/2016 JohnDoe REGULAR 25
5 10047 9/23/2016 JohnDoe HOLIDAY 25
6 10047 9/23/2016 JohnDoe SICK 25
7 10099 9/16/2016 ZachYork Vacation 24
8 10099 9/16/2016 ZachYork PTO 24
9 10200 9/16/2016 JessTill Vacation 20
10 10200 6/23/2016 JessTill PTO 25
11 10200 9/23/2016 JessTill TRAVEL 25
12 10500 9/16/2016 PaulDown REGULAR 22
Current Query
UPDATE [TableA] INNER JOIN TableA ON ([TableB].empl_no = [TableA].Employee_no) AND ([TableB].PEREND = [TableA].[PEREND]) SET TableA = [TableB].Visits
WHERE [TableA].IDNmbr IN (SELECT Min(IDNmbr)
FROM TableA
GROUP BY Employee_no,PEREND);
Any help is GREATLY appreciated. If I only knew in ACCESS what I know how to do in Excel and Excel VBA.
Willing to LEARN!
Thank you