Hi, I initially posted this in the database design forum and then realized it needs to go here. All help will be appreciated. I am an engineer that does not know Access very well, learning on the fly!
I am having to use an inherited Access database in my new job and I need to revise it. I don't know Access, I am learning Access on my own time. The database consists of 3 main tables: Part table, damage table, new records table. Part table has a column PartNumber where records are of the format XXXXXXXXX-YYYY, XXXXXXXXX-ZZZZ. The basic 9 digit number (XXXXXXXXX) can have multiple dash numbers (YYYY, ZZZZ, AAAA, etc.). New records table has column PartNumber with same record format, XXXXXXXXX-YYYY. I need to check New records table basic 9 digit number against Part table basic 9 digit number and if found, add New record to damage table. I generated the query below but it adds duplicate new records to the damage table. Can anyone help me out?
The append query is comparing the new records table with the part table and restricting the comparison to only the first 9 digits. The problem is that the part table contains part numbers such as fictitious PN 68A320009-1009, 68A320009-1010, etc.. So there almost always be more than one match in the part table. What needs to happen is to stop the comparison as soon as 1 match is found, append the new record to the damage table, and then go to the next record to compare.
INSERT INTO [damage table] (PartNumber)
SELECT [new records] (PartNumnber)
FROM [new records] INNER JOIN [part table] ON LEFT([new record].[PartNumber],9)=LEFT[part table].[PartNumber,9]);