Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Query

Status
Not open for further replies.

RENENGER

MIS
Feb 11, 2003
7
US
I am importing a .csv file into tblCSVImport. From there I am running a Make-Table query that copies all of that information into a tmptable with the correct field names. I am running another Make-Table query that groups that same information that will be the Main Table with the header information. However, when I create an update qry using the tmpHeader table and the actual header table, it won't update the information if it already exists. We may have changes to it or we might be adding new information. I get an error regarding duplicate errors because of the primary key setup in the primary table. However, I want it to overwrite the record if it already exists, if it doesn't I want the query to add it. Can someone help?

UPDATE tmptblFrontierMainUpdate LEFT JOIN tblMainFrontierUnits ON (tmptblFrontierMainUpdate.ProjectID = tblMainFrontierUnits.ProjectID) AND (tmptblFrontierMainUpdate.Phase = tblMainFrontierUnits.Phase) AND (tmptblFrontierMainUpdate.Unit = tblMainFrontierUnits.Unit) AND (tmptblFrontierMainUpdate.Tract = tblMainFrontierUnits.Tract) AND (tmptblFrontierMainUpdate.Release = tblMainFrontierUnits.Release) AND (tmptblFrontierMainUpdate.UnitPlan = tblMainFrontierUnits.UnitPlan) SET tblMainFrontierUnits.ProjectID = [tmptblFrontierMainUpdate].[ProjectId], tblMainFrontierUnits.Phase = [tmptblFrontierMainUpdate].[Phase], tblMainFrontierUnits.Unit = [tmptblFrontierMainUpdate].[Unit], tblMainFrontierUnits.Tract = [tmptblFrontierMainUpdate].[Tract], tblMainFrontierUnits.Release = [tmptblFrontierMainUpdate].[Release], tblMainFrontierUnits.UnitPlan = [tmptblFrontierMainUpdate].[UnitPlan];
 
Ok. I am an idiot I got this to work. My main table update query will update or add to what I already have. My problem now is with the details table. If I have two rows for one unit, it will only input one of them. For example, I add the following to the .csv file:

80506 ANTHONY 19 72 , , 419 , N N , PLAN 20 RO CC21 0
80506 ANTHONY 19 72 , , 419 REV N N , PLAN 20 RO CC21 0

Because the is something different between the first 8 fields it should allow this to go into the details. However, it's only adding the one with the REV. I am not getting any error messages.

Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top