Hi,
I'd suggest you try the following methods in order to recover your VBA code-
NOTE- Before trying any of these methods, please keep a backup.
- Use the in-built utility by MS Access known as "Compact and Repair".
- Create a new access database and import the objects (tables, queries, forms, reports, modules, etc.) from the corrupted database into this new access database.
- If the above methods don't work, you should consider using a third-party tool specifically designed to recover data from corrupted Access databases like DataNumen, Stellar etc.
You can also try some more methods mentioned in this link in order to fix this error.. https://learn.microsoft.com/en-us/office/troubleshoot/access/error-inserting-table-record-autonumber
Best Regards.