I now know exactly what is causing the problem.
When ever we get a breakdown, we create a jobsheet which is later turned into an invoice.
All jobsheets and invoices have a matching unique ID, known as an FI Number.
When the query runs, it looks at the FI number which joins the invoice & job tables, and pulls in wheel positions, tyre sizes etc.
When an account credit is issued to refund a breakdown gone wrong, it creates an FR Number in the invoice table, which therefore cannot link to the corresponding FI number on the job record, causing the mismatch error on the join
I have tried excluding all records which begin with FR, but it still returns the error. Here is the full query SQL:
INSERT INTO [Historical Casing Jobs] ( CUSTOMER, INVNUM, DELIVERY, INVDATE, REGNUM, [POSITION], TREADM, SERIALON, SERIALOFF, [SECTION], PROFILE, RIM, [SIZE], [New Or Rems], STCODE, Brand, [Removal Description], DESCRIPN, [Post Code], OLDADVNUM, [Retreader Agent], SUMCODE, NAME1, VAN, Destination, [Pos No] )
SELECT TRNLIST.CUSTOMER, TRNLIST.INVNUM, TRNLIST.DELIVERY, TRNLIST.INVDATE, TRNLIST.REGNUM, Positions.[Position Name], TRANSFI.TREADM, TRANSFI.SERIALON, TRANSFI.SERIALOFF, STOCK.SECTION, STOCK.PROFILE, STOCK.RIM, [SECTION] & "/" & [PROFILE] & "R" & [RIM] AS [SIZE], [Tbl New Rems Code].[New or Rems], TRANSFI.STCODE, [Tbl Tyre Manufacturers].Brand, [Tbl Removal Codes].[Removal Description], VANRUN.DESCRIPN, VANRUN.[Post Code], TRNLIST.OLDADVNUM, [Tbl Retreader-Dealer Assoc].[Retreader Agent], STOCK.SUMCODE, TRNLIST.NAME1, TRNLIST.VAN, Destination.Destination, TRANSFI.POSITION
FROM Positions INNER JOIN (Destination INNER JOIN ((((((((TRNLIST INNER JOIN TRANSFI ON TRNLIST.INVNUM = TRANSFI.DOCUMENT) LEFT JOIN STOCK ON TRANSFI.STCODE = STOCK.STCODE) LEFT JOIN [Tbl Removal Codes] ON TRANSFI.REASON = [Tbl Removal Codes].[Removal Code]) LEFT JOIN [Tbl Tyre Manufacturers] ON TRANSFI.BRAND = [Tbl Tyre Manufacturers].Code) LEFT JOIN [Tbl New Rems Code] ON TRANSFI.REMOULD = [Tbl New Rems Code].[New Rems Code]) LEFT JOIN VANRUN ON TRNLIST.VAN = VANRUN.NUMBER) INNER JOIN [Tbl Retreader-Dealer Assoc] ON TRNLIST.VAN = [Tbl Retreader-Dealer Assoc].[VANRUN Number]) INNER JOIN [Tbl Customer Retreader Association] ON (TRNLIST.CUSTOMER = [Tbl Customer Retreader Association].[Customer Code]) AND ([Tbl Retreader-Dealer Assoc].Retreader = [Tbl Customer Retreader Association].[Retreader Agent])) ON Destination.[Dest No] = TRANSFI.CASDEST) ON Positions.[Position No] = TRANSFI.POSITION
WHERE (((TRNLIST.INVNUM) Not Like '%FR%') AND ((TRNLIST.INVDATE)>=Date()-45) AND ((Positions.[Position Name]) Is Not Null) AND (([SECTION] & "/" & [PROFILE] & "R" & [RIM])<>"/R"))
ORDER BY TRNLIST.INVNUM;
How can i exclude all records which have an FR ID so that access does not attempt to make the join and throw an error back at the user?
Thanks for your help & getting me this far!!
