O
owp^3
Once a week I receive an Excel File with 300+ records and each record has 30
Fields. I then add a 31st field to hold the date I received the file. Each
record has a key called Portfolio ID.
I have built two tables with 32 fields (the 31 in the excel worksheet and an
autonumbered key). The first will house the "transactional" records
accumulated over time. The second will serve as a "staging" table to house
the records imported records from the current week's file.
I want to append the transactional table with records from the staging table
if the Portfolio ID does not exist in the transactional table OR if any of
the fields for an existing Portfolio ID have changed since the last record
for that Portfolio ID.
I created a select query to pull the most recent record for each Portfolio
ID in the transactional table:
SELECT [data_BTPortfolioWeekly-Projectview].[BT Portfolio ID],
[data_BTPortfolioWeekly-Projectview].[BT Status],
[data_BTPortfolioWeekly-Projectview].[BT Type],
[data_BTPortfolioWeekly-Projectview].[BT Title],
[data_BTPortfolioWeekly-Projectview].[BT Description],
[data_BTPortfolioWeekly-Projectview].[BT BU Priority],
[data_BTPortfolioWeekly-Projectview].[BT BU],
[data_BTPortfolioWeekly-Projectview].[BT BU Sponsor],
[data_BTPortfolioWeekly-Projectview].[BT BU PM],
[data_BTPortfolioWeekly-Projectview].[BT Financials],
[data_BTPortfolioWeekly-Projectview].[BT BU in Plan],
[data_BTPortfolioWeekly-Projectview].[BT BU Planned Target],
[data_BTPortfolioWeekly-Projectview].[BT Proposal Received],
[data_BTPortfolioWeekly-Projectview].[BT Project Start],
[data_BTPortfolioWeekly-Projectview].[BT Requirements Sign-off],
[data_BTPortfolioWeekly-Projectview].[BT Phase],
[data_BTPortfolioWeekly-Projectview].[BT Phase Due],
[data_BTPortfolioWeekly-Projectview].[BT Comitted Flag],
[data_BTPortfolioWeekly-Projectview].[BT Target Install],
[data_BTPortfolioWeekly-Projectview].[BT Duration],
[data_BTPortfolioWeekly-Projectview].[BT PSA Risk Category],
[data_BTPortfolioWeekly-Projectview].[BT Health Indicator],
[data_BTPortfolioWeekly-Projectview].[BT Executive Status],
[data_BTPortfolioWeekly-Projectview].[BT Manager],
[data_BTPortfolioWeekly-Projectview].[BT Director],
[data_BTPortfolioWeekly-Projectview].[BT Project Manager],
[data_BTPortfolioWeekly-Projectview].[PF BHP],
[data_BTPortfolioWeekly-Projectview].[PF Capital],
[data_BTPortfolioWeekly-Projectview].[PF BT Cross Functional],
[data_BTPortfolioWeekly-Projectview].[PF Production Assurance],
Max([data_BTPortfolioWeekly-Projectview].[BT Report Date]) AS [MaxOfBT Report
Date]
FROM [data_BTPortfolioWeekly-Projectview]
GROUP BY [data_BTPortfolioWeekly-Projectview].[BT Portfolio ID],
[data_BTPortfolioWeekly-Projectview].[BT Status],
[data_BTPortfolioWeekly-Projectview].[BT Type],
[data_BTPortfolioWeekly-Projectview].[BT Title],
[data_BTPortfolioWeekly-Projectview].[BT Description],
[data_BTPortfolioWeekly-Projectview].[BT BU Priority],
[data_BTPortfolioWeekly-Projectview].[BT BU],
[data_BTPortfolioWeekly-Projectview].[BT BU Sponsor],
[data_BTPortfolioWeekly-Projectview].[BT BU PM],
[data_BTPortfolioWeekly-Projectview].[BT Financials],
[data_BTPortfolioWeekly-Projectview].[BT BU in Plan],
[data_BTPortfolioWeekly-Projectview].[BT BU Planned Target],
[data_BTPortfolioWeekly-Projectview].[BT Proposal Received],
[data_BTPortfolioWeekly-Projectview].[BT Project Start],
[data_BTPortfolioWeekly-Projectview].[BT Requirements Sign-off],
[data_BTPortfolioWeekly-Projectview].[BT Phase],
[data_BTPortfolioWeekly-Projectview].[BT Phase Due],
[data_BTPortfolioWeekly-Projectview].[BT Comitted Flag],
[data_BTPortfolioWeekly-Projectview].[BT Target Install],
[data_BTPortfolioWeekly-Projectview].[BT Duration],
[data_BTPortfolioWeekly-Projectview].[BT PSA Risk Category],
[data_BTPortfolioWeekly-Projectview].[BT Health Indicator],
[data_BTPortfolioWeekly-Projectview].[BT Executive Status],
[data_BTPortfolioWeekly-Projectview].[BT Manager],
[data_BTPortfolioWeekly-Projectview].[BT Director],
[data_BTPortfolioWeekly-Projectview].[BT Project Manager],
[data_BTPortfolioWeekly-Projectview].[PF BHP],
[data_BTPortfolioWeekly-Projectview].[PF Capital],
[data_BTPortfolioWeekly-Projectview].[PF BT Cross Functional],
[data_BTPortfolioWeekly-Projectview].[PF Production Assurance];
Next I have created this append query:
INSERT INTO [data_BTPortfolioWeekly-Projectview] ( [BT Portfolio ID], [BT
Status], [BT Type], [BT Title], [BT Description], [BT BU Priority], [BT BU],
[BT BU Sponsor], [BT BU PM], [BT Financials], [BT BU in Plan], [BT BU Planned
Target], [BT Proposal Received], [BT Project Start], [BT Requirements
Sign-off], [BT Phase], [BT Phase Due], [BT Comitted Flag], [BT Target
Install], [BT Duration], [BT PSA Risk Category], [BT Health Indicator], [BT
Executive Status], [BT Manager], [BT Director], [BT Project Manager], [PF
BHP], [PF Capital], [PF BT Cross Functional], [PF Production Assurance], [BT
Report Date] )
SELECT [import_BTPortfolioWeekly-Projectview].[BT Portfolio ID],
[import_BTPortfolioWeekly-Projectview].[BT Status],
[import_BTPortfolioWeekly-Projectview].[BT Type],
[import_BTPortfolioWeekly-Projectview].[BT Title],
[import_BTPortfolioWeekly-Projectview].[BT Description],
[import_BTPortfolioWeekly-Projectview].[BT BU Priority],
[import_BTPortfolioWeekly-Projectview].[BT BU],
[import_BTPortfolioWeekly-Projectview].[BT BU Sponsor],
[import_BTPortfolioWeekly-Projectview].[BT BU PM],
[import_BTPortfolioWeekly-Projectview].[BT Financials],
[import_BTPortfolioWeekly-Projectview].[BT BU in Plan],
[import_BTPortfolioWeekly-Projectview].[BT BU Planned Target],
[import_BTPortfolioWeekly-Projectview].[BT Proposal Received],
[import_BTPortfolioWeekly-Projectview].[BT Project Start],
[import_BTPortfolioWeekly-Projectview].[BT Requirements Sign-off],
[import_BTPortfolioWeekly-Projectview].[BT Phase],
[import_BTPortfolioWeekly-Projectview].[BT Phase Due],
[import_BTPortfolioWeekly-Projectview].[BT Comitted Flag],
[import_BTPortfolioWeekly-Projectview].[BT Target Install],
[import_BTPortfolioWeekly-Projectview].[BT Duration],
[import_BTPortfolioWeekly-Projectview].[BT PSA Risk Category],
[import_BTPortfolioWeekly-Projectview].[BT Health Indicator],
[import_BTPortfolioWeekly-Projectview].[BT Executive Status],
[import_BTPortfolioWeekly-Projectview].[BT Manager],
[import_BTPortfolioWeekly-Projectview].[BT Director],
[import_BTPortfolioWeekly-Projectview].[BT Project Manager],
[import_BTPortfolioWeekly-Projectview].[PF BHP],
[import_BTPortfolioWeekly-Projectview].[PF Capital],
[import_BTPortfolioWeekly-Projectview].[PF BT Cross Functional],
[import_BTPortfolioWeekly-Projectview].[PF Production Assurance],
[import_BTPortfolioWeekly-Projectview].[BT Report Date]
FROM [import_BTPortfolioWeekly-Projectview]
WHERE ((([import_BTPortfolioWeekly-Projectview]![BT Portfolio
ID])=[select_ProjectView-LastUpdate]![BT Portfolio ID])) OR
((([import_BTPortfolioWeekly-Projectview]![BT
Status])<>[select_ProjectView-LastUpdate]![BT Status]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Type])<>[select_ProjectView-LastUpdate]![BT Type]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Title])<>[select_ProjectView-LastUpdate]![BT Title]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Description])<>[select_ProjectView-LastUpdate]![BT Description]) AND
(([import_BTPortfolioWeekly-Projectview]![BT BU
Priority])<>[select_ProjectView-LastUpdate]![BT BU Priority]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
BU])<>[select_ProjectView-LastUpdate]![BT BU]) AND
(([import_BTPortfolioWeekly-Projectview]![BT BU
Sponsor])<>[select_ProjectView-LastUpdate]![BT BU Sponsor]) AND
(([import_BTPortfolioWeekly-Projectview]![BT BU
PM])<>[select_ProjectView-LastUpdate]![BT BU PM]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Project
Start])<>[select_ProjectView-LastUpdate]![BT Project Start]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Requirements
Sign-off])<>[select_ProjectView-LastUpdate]![BT Requirements Sign-off]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Phase])<>[select_ProjectView-LastUpdate]![BT Phase]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Phase
Due])<>[select_ProjectView-LastUpdate]![BT Phase Due]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Comitted
Flag])<>[select_ProjectView-LastUpdate]![BT Comitted Flag]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Target
Instal])<>[select_ProjectView-LastUpdate]![BT Target Instal]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Duration])<>[select_ProjectView-LastUpdate]![BT Duration]) AND
(([import_BTPortfolioWeekly-Projectview]![BT PSA Risk
Category])<>[select_ProjectView-LastUpdate]![BT PSA Risk Category]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Health
Indicator])<>[select_ProjectView-LastUpdate]![BT Health Indicator]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Executive
Status])<>[select_ProjectView-LastUpdate]![BT Executive Status]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Manager])<>[select_ProjectView-LastUpdate]![BT Manager]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Director])<>[select_ProjectView-LastUpdate]![BT Director]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Project
Manager])<>[select_ProjectView-LastUpdate]![BT Project Manager]) AND
(([import_BTPortfolioWeekly-Projectview]![PF
BHP])<>[select_ProjectView-LastUpdate]![PF BHP]) AND
(([import_BTPortfolioWeekly-Projectview]![PF
Capital])<>[select_ProjectView-LastUpdate]![PF Capital]) AND
(([import_BTPortfolioWeekly-Projectview]![PF BT Cross
Functional])<>[select_ProjectView-LastUpdate]![PF BT Cross Functional]) AND
(([import_BTPortfolioWeekly-Projectview]![PF Production
Assurance])<>[select_ProjectView-LastUpdate]![PF Production Assurance]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Report
Date])>[select_ProjectView-LastUpdate]![MaxOfBT Report Date]));
When I run the append query it asks me to Enter A Parameter Value
select_ProjectView-LastUpdate!BT Portfolio ID
What did I do wrong and how do I fix it?
Or is there an easier/better way to reach my goal of tracking changes over
time?
Thanks,
Fields. I then add a 31st field to hold the date I received the file. Each
record has a key called Portfolio ID.
I have built two tables with 32 fields (the 31 in the excel worksheet and an
autonumbered key). The first will house the "transactional" records
accumulated over time. The second will serve as a "staging" table to house
the records imported records from the current week's file.
I want to append the transactional table with records from the staging table
if the Portfolio ID does not exist in the transactional table OR if any of
the fields for an existing Portfolio ID have changed since the last record
for that Portfolio ID.
I created a select query to pull the most recent record for each Portfolio
ID in the transactional table:
SELECT [data_BTPortfolioWeekly-Projectview].[BT Portfolio ID],
[data_BTPortfolioWeekly-Projectview].[BT Status],
[data_BTPortfolioWeekly-Projectview].[BT Type],
[data_BTPortfolioWeekly-Projectview].[BT Title],
[data_BTPortfolioWeekly-Projectview].[BT Description],
[data_BTPortfolioWeekly-Projectview].[BT BU Priority],
[data_BTPortfolioWeekly-Projectview].[BT BU],
[data_BTPortfolioWeekly-Projectview].[BT BU Sponsor],
[data_BTPortfolioWeekly-Projectview].[BT BU PM],
[data_BTPortfolioWeekly-Projectview].[BT Financials],
[data_BTPortfolioWeekly-Projectview].[BT BU in Plan],
[data_BTPortfolioWeekly-Projectview].[BT BU Planned Target],
[data_BTPortfolioWeekly-Projectview].[BT Proposal Received],
[data_BTPortfolioWeekly-Projectview].[BT Project Start],
[data_BTPortfolioWeekly-Projectview].[BT Requirements Sign-off],
[data_BTPortfolioWeekly-Projectview].[BT Phase],
[data_BTPortfolioWeekly-Projectview].[BT Phase Due],
[data_BTPortfolioWeekly-Projectview].[BT Comitted Flag],
[data_BTPortfolioWeekly-Projectview].[BT Target Install],
[data_BTPortfolioWeekly-Projectview].[BT Duration],
[data_BTPortfolioWeekly-Projectview].[BT PSA Risk Category],
[data_BTPortfolioWeekly-Projectview].[BT Health Indicator],
[data_BTPortfolioWeekly-Projectview].[BT Executive Status],
[data_BTPortfolioWeekly-Projectview].[BT Manager],
[data_BTPortfolioWeekly-Projectview].[BT Director],
[data_BTPortfolioWeekly-Projectview].[BT Project Manager],
[data_BTPortfolioWeekly-Projectview].[PF BHP],
[data_BTPortfolioWeekly-Projectview].[PF Capital],
[data_BTPortfolioWeekly-Projectview].[PF BT Cross Functional],
[data_BTPortfolioWeekly-Projectview].[PF Production Assurance],
Max([data_BTPortfolioWeekly-Projectview].[BT Report Date]) AS [MaxOfBT Report
Date]
FROM [data_BTPortfolioWeekly-Projectview]
GROUP BY [data_BTPortfolioWeekly-Projectview].[BT Portfolio ID],
[data_BTPortfolioWeekly-Projectview].[BT Status],
[data_BTPortfolioWeekly-Projectview].[BT Type],
[data_BTPortfolioWeekly-Projectview].[BT Title],
[data_BTPortfolioWeekly-Projectview].[BT Description],
[data_BTPortfolioWeekly-Projectview].[BT BU Priority],
[data_BTPortfolioWeekly-Projectview].[BT BU],
[data_BTPortfolioWeekly-Projectview].[BT BU Sponsor],
[data_BTPortfolioWeekly-Projectview].[BT BU PM],
[data_BTPortfolioWeekly-Projectview].[BT Financials],
[data_BTPortfolioWeekly-Projectview].[BT BU in Plan],
[data_BTPortfolioWeekly-Projectview].[BT BU Planned Target],
[data_BTPortfolioWeekly-Projectview].[BT Proposal Received],
[data_BTPortfolioWeekly-Projectview].[BT Project Start],
[data_BTPortfolioWeekly-Projectview].[BT Requirements Sign-off],
[data_BTPortfolioWeekly-Projectview].[BT Phase],
[data_BTPortfolioWeekly-Projectview].[BT Phase Due],
[data_BTPortfolioWeekly-Projectview].[BT Comitted Flag],
[data_BTPortfolioWeekly-Projectview].[BT Target Install],
[data_BTPortfolioWeekly-Projectview].[BT Duration],
[data_BTPortfolioWeekly-Projectview].[BT PSA Risk Category],
[data_BTPortfolioWeekly-Projectview].[BT Health Indicator],
[data_BTPortfolioWeekly-Projectview].[BT Executive Status],
[data_BTPortfolioWeekly-Projectview].[BT Manager],
[data_BTPortfolioWeekly-Projectview].[BT Director],
[data_BTPortfolioWeekly-Projectview].[BT Project Manager],
[data_BTPortfolioWeekly-Projectview].[PF BHP],
[data_BTPortfolioWeekly-Projectview].[PF Capital],
[data_BTPortfolioWeekly-Projectview].[PF BT Cross Functional],
[data_BTPortfolioWeekly-Projectview].[PF Production Assurance];
Next I have created this append query:
INSERT INTO [data_BTPortfolioWeekly-Projectview] ( [BT Portfolio ID], [BT
Status], [BT Type], [BT Title], [BT Description], [BT BU Priority], [BT BU],
[BT BU Sponsor], [BT BU PM], [BT Financials], [BT BU in Plan], [BT BU Planned
Target], [BT Proposal Received], [BT Project Start], [BT Requirements
Sign-off], [BT Phase], [BT Phase Due], [BT Comitted Flag], [BT Target
Install], [BT Duration], [BT PSA Risk Category], [BT Health Indicator], [BT
Executive Status], [BT Manager], [BT Director], [BT Project Manager], [PF
BHP], [PF Capital], [PF BT Cross Functional], [PF Production Assurance], [BT
Report Date] )
SELECT [import_BTPortfolioWeekly-Projectview].[BT Portfolio ID],
[import_BTPortfolioWeekly-Projectview].[BT Status],
[import_BTPortfolioWeekly-Projectview].[BT Type],
[import_BTPortfolioWeekly-Projectview].[BT Title],
[import_BTPortfolioWeekly-Projectview].[BT Description],
[import_BTPortfolioWeekly-Projectview].[BT BU Priority],
[import_BTPortfolioWeekly-Projectview].[BT BU],
[import_BTPortfolioWeekly-Projectview].[BT BU Sponsor],
[import_BTPortfolioWeekly-Projectview].[BT BU PM],
[import_BTPortfolioWeekly-Projectview].[BT Financials],
[import_BTPortfolioWeekly-Projectview].[BT BU in Plan],
[import_BTPortfolioWeekly-Projectview].[BT BU Planned Target],
[import_BTPortfolioWeekly-Projectview].[BT Proposal Received],
[import_BTPortfolioWeekly-Projectview].[BT Project Start],
[import_BTPortfolioWeekly-Projectview].[BT Requirements Sign-off],
[import_BTPortfolioWeekly-Projectview].[BT Phase],
[import_BTPortfolioWeekly-Projectview].[BT Phase Due],
[import_BTPortfolioWeekly-Projectview].[BT Comitted Flag],
[import_BTPortfolioWeekly-Projectview].[BT Target Install],
[import_BTPortfolioWeekly-Projectview].[BT Duration],
[import_BTPortfolioWeekly-Projectview].[BT PSA Risk Category],
[import_BTPortfolioWeekly-Projectview].[BT Health Indicator],
[import_BTPortfolioWeekly-Projectview].[BT Executive Status],
[import_BTPortfolioWeekly-Projectview].[BT Manager],
[import_BTPortfolioWeekly-Projectview].[BT Director],
[import_BTPortfolioWeekly-Projectview].[BT Project Manager],
[import_BTPortfolioWeekly-Projectview].[PF BHP],
[import_BTPortfolioWeekly-Projectview].[PF Capital],
[import_BTPortfolioWeekly-Projectview].[PF BT Cross Functional],
[import_BTPortfolioWeekly-Projectview].[PF Production Assurance],
[import_BTPortfolioWeekly-Projectview].[BT Report Date]
FROM [import_BTPortfolioWeekly-Projectview]
WHERE ((([import_BTPortfolioWeekly-Projectview]![BT Portfolio
ID])=[select_ProjectView-LastUpdate]![BT Portfolio ID])) OR
((([import_BTPortfolioWeekly-Projectview]![BT
Status])<>[select_ProjectView-LastUpdate]![BT Status]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Type])<>[select_ProjectView-LastUpdate]![BT Type]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Title])<>[select_ProjectView-LastUpdate]![BT Title]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Description])<>[select_ProjectView-LastUpdate]![BT Description]) AND
(([import_BTPortfolioWeekly-Projectview]![BT BU
Priority])<>[select_ProjectView-LastUpdate]![BT BU Priority]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
BU])<>[select_ProjectView-LastUpdate]![BT BU]) AND
(([import_BTPortfolioWeekly-Projectview]![BT BU
Sponsor])<>[select_ProjectView-LastUpdate]![BT BU Sponsor]) AND
(([import_BTPortfolioWeekly-Projectview]![BT BU
PM])<>[select_ProjectView-LastUpdate]![BT BU PM]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Project
Start])<>[select_ProjectView-LastUpdate]![BT Project Start]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Requirements
Sign-off])<>[select_ProjectView-LastUpdate]![BT Requirements Sign-off]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Phase])<>[select_ProjectView-LastUpdate]![BT Phase]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Phase
Due])<>[select_ProjectView-LastUpdate]![BT Phase Due]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Comitted
Flag])<>[select_ProjectView-LastUpdate]![BT Comitted Flag]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Target
Instal])<>[select_ProjectView-LastUpdate]![BT Target Instal]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Duration])<>[select_ProjectView-LastUpdate]![BT Duration]) AND
(([import_BTPortfolioWeekly-Projectview]![BT PSA Risk
Category])<>[select_ProjectView-LastUpdate]![BT PSA Risk Category]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Health
Indicator])<>[select_ProjectView-LastUpdate]![BT Health Indicator]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Executive
Status])<>[select_ProjectView-LastUpdate]![BT Executive Status]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Manager])<>[select_ProjectView-LastUpdate]![BT Manager]) AND
(([import_BTPortfolioWeekly-Projectview]![BT
Director])<>[select_ProjectView-LastUpdate]![BT Director]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Project
Manager])<>[select_ProjectView-LastUpdate]![BT Project Manager]) AND
(([import_BTPortfolioWeekly-Projectview]![PF
BHP])<>[select_ProjectView-LastUpdate]![PF BHP]) AND
(([import_BTPortfolioWeekly-Projectview]![PF
Capital])<>[select_ProjectView-LastUpdate]![PF Capital]) AND
(([import_BTPortfolioWeekly-Projectview]![PF BT Cross
Functional])<>[select_ProjectView-LastUpdate]![PF BT Cross Functional]) AND
(([import_BTPortfolioWeekly-Projectview]![PF Production
Assurance])<>[select_ProjectView-LastUpdate]![PF Production Assurance]) AND
(([import_BTPortfolioWeekly-Projectview]![BT Report
Date])>[select_ProjectView-LastUpdate]![MaxOfBT Report Date]));
When I run the append query it asks me to Enter A Parameter Value
select_ProjectView-LastUpdate!BT Portfolio ID
What did I do wrong and how do I fix it?
Or is there an easier/better way to reach my goal of tracking changes over
time?
Thanks,