Link to home
Start Free TrialLog in
Avatar of Conernesto
ConernestoFlag for United States of America

asked on

Replace a Module in Access Database

I have a module called modExel. I want to replace this module with a different module with the same name. The new module is modExcel.bas. How do I replace the current module on my database with the new one? I know that you do Alt F11 to open the modules from Access.
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

from the database objects window,
select Modules
right click on the module modExel and select copy, then Paste, give it a new name

or just rename your module
right click on the module modExel and select Rename
An easy way to do this is to
1.  Make a backup of your existing database before adding the new code

2.  Select ALL and copy all of the code from the new module, and paste it to the old, *overwriting all of the existing code in the original module*

The reason you want to overwrite the existing module is so that you do not have multiple copies of public subs and functions with the same names -- which will cause your code to error on procedure calls because of ambiguous names.
and, take note that you can not use the name "modExcel.bas", but you can use

modExcelbas  without the dot
Avatar of Conernesto

ASKER

I want to import my new module. When I go to, File Import if I don't have the .bas extension, I cannot select it. When I save it it doesn't save with the same name that I imported. That is why I want to delete the current module and import the new one. How do I do this?
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
right click on the module then select delete

File >external data> import > select the access file

then select the module you want to import
This is it in Access 2010 -- other versions may look different.  External Data, selecting the Access icon will let you import or export modules, forms, etc from one database to another.

User generated image