0

I wrote a function in visual basic which I can use in any query or form of given access database by adding the module. What I want is to able to use the function in all the databases in my machine. A simple solution is to copy the module everytime to the database, but is there any simple solution?

In excel you can do this by adding the function to a .xla file and then copying the file to XLSTART folder. But MSACCESS doesn't have any such equivalent folder.

Can someone suggest something?

1 Answers1

1

Here is a complete tutorial: Using a centralized VBA module in multiple Access databases

  1. Make your "helper" database. Put a few procedures in there.
  2. In your 'client' databases, open the VBA Editor
  3. Go to Tools->References. Browse and select your helper database.
  4. Done! You can now use all the functions in your helper database throughout your client databases.

[EDIT]

There's no way (and it's really unnecessary) to create database which automatically starts with MS Access application.

I think that you're looking for a way to create template database which contains the set of custom objects, such as tables, vba module(s), forms, queries, etc.

See:
Save and reuse database design elements
Easy Access with templates I: Create a database

Community
  • 1
  • 1
Maciej Los
  • 8,468
  • 1
  • 20
  • 35
  • Yaa I saw that post, better than creating a helper database and adding its reference everytime, I can write my vba code in a .bas file and just import the code into VBA Editor. But I want a better solution, which doesn't need any tweaking in every database. – Sainath Motlakunta Jan 05 '15 at 18:35
  • Why do you think it is unecessary? I know that you can create a template database, but what if u want to incorporate ur code in many existing databases? – Sainath Motlakunta Jan 06 '15 at 13:29
  • Unnecessary, because MS Access is a GUI for database engine and does not allow to open mulitple databases in a single instance of application. It totally differs from MS Excel. If you want to incorporate your code in many existing databases, create helper database and add reference to it in each existing database. – Maciej Los Jan 06 '15 at 13:59