0

We got a ms-access database we use as a framework.

So we use a function we call "Update framework" where we transfer some modules from the framework to the target database with this code

db_fw.DoCmd.DeleteObject xxx_obj_t, rec_ref!REFR_NAME
...
db_fw.DoCmd.TransferDatabase acImport, "Microsoft Access", dCopiedFrameworkFile, xxx_obj_t, rec_ref!REFR_NAME, rec_ref!REFR_NAME

This works fine about 99% of the times.

But since some time I found out that sometimes - very rarely - instead of replacing the module, ms-access creates a module with the same name but a number at the end.

e.g. Module "ICanAfterStart" is not visible anymore. Instead a module "ICanAfterStart1" is visible. All the code works as before. So "implements ICanAfterStart" still compiles and seems to work.

When I update the framework once again, a module named: "ICanAfterStart2" (and so on) is created.

Until now this only happened with interface modules which we always name with an "I" at the beginning.

I already tried:

  • decompile the database

  • compress & repair the database

  • Application.SaveAsText; delete all visible "ICanAfterStart*" modules and try to use Application.LoadFromText to reimport the module. But Application.LoadFromText results in an "run-time-error 2950: reserved error"

  • I created a new module called "ICanAfterStart" where I copied the code as text into. But after the next framework update "ICanAfterStart" is not visible anymore and "ICanAfterStart1" is there.

As a "solution" for the moment I try backup files until I find one which does not have this error. As this is a lot of work and I have to recreate all the code I wrote until then, this is a bad solution.

So, does anyone know what the problem is and got a more practical solution for me?

Gener4tor
  • 414
  • 3
  • 12
  • 40
  • `run-time-error 2950: reserved error` often generates a text file in the same directory as your database with a more descriptive error. Can you check if such a file exists, and if so, provide its content? I've experienced similar problems that could be fixed by refreshing the navigation pane (`Application.RefreshDatabaseWindow`) after all deletes, but that didn't get error 2950. – Erik A Sep 19 '19 at 09:56
  • Did you do the Decompile [the right way](https://stackoverflow.com/a/3268188/3820271) ? – Andre Sep 19 '19 at 10:17
  • probably your DeleteObject for some reason it fails...do some logging to see that probably this is the culprit....maybe you could use a loop to try and delete the object..check if its deleted and gain retry if it fails...maybe 2-3 times should be enough and then exit the procedure notifying about the failure – John Sep 19 '19 at 10:21
  • @ Erik A: Application.RefreshDatabaseWindow does not change anything and unfortunately there is no textfile in the database folder. – Gener4tor Sep 19 '19 at 10:39

1 Answers1

0

You have to delete the original ones and the copie modules (ICanAfterStart, ICanAfterStart1, ICanAfterStart2,...) with the Project Explorer in the VBA-Development-Enviroment and reinport them.

Gener4tor
  • 414
  • 3
  • 12
  • 40