We are importing some code modules into an Access 2002 application using the below line in VBA
Application.VBE.ActiveVBProject.VBComponents.Import (strFileName)
This part works fine, the line immediately following attempts to save the new class to the project. The only way that we can see to do this is using DoCmd:
DoCmd.Save acModule, strModuleName
SOMETIMES, this results in error 2486: You can't carry out this action at the present time.
A longer version of the error gives the following:
You can't carry out this action at the present time. You tried to run a macro or used the DoCmd object in Visual Basic to carry out an action. However, Microsoft Access is performing another activity that prevents this action from being carried out now.
The fact that this says "Access is performing another activity" seems to make sense as we only get the error sometimes. Is there a way to know what is is busy doing and waiting for it to finish? Or is there a better way to implement the importing of modules?
I thought about writing something that would while until module.Saved property is true, but this code is nasty enough without that....