How can I get rid of this message without changing the reference number?
You can not as it will show that there is a duplicate reference number. Most tax authorities in most countries require unique reference numbers for purchase and sales invoices. Those countries that are more advanced do e-invoicing with government assigned numbers or authorizations to prevent duplication.
As such I would recommend changing the reference numbers so that each invoice is unique.
In addition to my previous reply I assume your business is in the Netherlands. As such the information about invoices (facturatie) by the tax authorities is available at Aan welke eisen moeten facturen voldoen voor uw btw-administratie? (What requirements must invoices meet for your VAT administration?)
It states in Dutch (emphasis added where request for unique numbers)
- een factuurnummer
Gebruik opeenvolgende nummers voor uw facturen, met 1 of meer reeksen. Elk factuurnummer mag maar 1 keer voorkomen.
Translated to English for forum (emphasis added where request for unique numbers)
an invoice number
Use sequential numbers for your invoices, with 1 or more series. Each invoice number may only occur once.
You could add a letter as a prefix for the duplicate ones using batch update.
Then sorting doesn’t work correct.
Then all the invoices don’t corresponds anymore
You are absolutely right. I made this mistake years ago when there was no check by Manager for duplicate numbers. If I change the number, the number on the corresponding invoice is no longer correct.