Welcome to MSDN Blogs Sign in | Join | Help

Microsoft Access Team Blog

Get product announcements, tips and tricks, and news directly from the team @ Microsoft.
Tell us how you organize code snippets

Many of the Access developers I have meet have a system for organizing code snippets. You know, the common fragments of code that are reuse for project after project. We are interested in learning more about readers of this blog organize code that is useful from one project to another. Do you store the fragments in text files, html files, database tables with meta data?

Please tell us more!

Posted: Wednesday, March 12, 2008 8:44 PM by Clint Covington
Filed under:

Comments

grovelli said:

I use a library mdb storing all the snippets.

I know there's also Visual SourceSafe which allows to check in/out all the database objects but never got around to use it.

# March 13, 2008 4:19 AM

Garry said:

I keep mine in carefully titled text files organised in folders and subfolders for quick retrieval.

I often add notes before the snippet to remind me how and when to use the code.

Garry

# March 13, 2008 5:02 AM

Brandon said:

I use master modules that are version controlled (just by a quick date notation at the top) and categorized by type of function.  If I need to make a mod to a routine for a specific database or purpose, it needs to be compatible with all the other databases where it's used.  If that isn't possible, it becomes a database-specific routine in it's own module.  That keeps most of my databases down to about 8 generic modules that are easy to upgrade and cascade updates by complete replacement, and one module that is specific to the current database.

# March 13, 2008 8:49 AM

grovelli said:

Hi Brandon, do you cascade-update manually or do you apply some automation to the process?

# March 13, 2008 9:26 AM

pdebaets said:

I have a text file with function and subroutine templates in it.

Also, I have a set of generic functions that can work in any application (they all start with "xg_ ..." - a naming convention I borrowed from somewhere)  that I can usually copy from the last project I worked on.

Also, to find any routine I've worked on in the past, I wrote a db that reads through my entire library of .mdb files, finds function and subroutine names, puts them into a table with their location and displays the results in a sortable list box (it tales a while to run). I can then double-click on any entry and the target db opens and the routine is displayed for copying.

# March 13, 2008 11:04 AM

grovelli said:

Peter, that's impressive, I suppose for you to share the code that does that is asking too much? :-)

# March 13, 2008 11:54 AM

KiwiBruce said:

I use a code Library database to keep all my common Forms,Tables and code modules in and pull them into projects as needed, No cool update process like Peter :)

Also for small Snippets and error handling I use mztools from http://mztools.com. Check it out the best (free) add-in around It saves hours and hours of coding! there are too many features to list, but, the Add Code template is awesome for small snippets and he one button error handling and  procedure header is wonderful. Most of this stuff should be in the IDE to start with.

Bruce

# March 13, 2008 1:51 PM

Jon Peltier said:

I do what Garry does. A deep and broad directory structure filled with text files and a few exported modules. Here and there if I have a userform, I'll save a workbook that contains the form and its code as well as the minimum commands needed to invoke the form.

# March 13, 2008 6:03 PM

John Marsing said:

I use MZ-Tools for vba, web site www.mztools.com

# March 13, 2008 10:17 PM

Peter Schmidt said:

I have a base mdb file that has modules containing my standard functions for user authentication, linking tables, etc, plus a standard menu, setup tables, a standard report library form and form templates.

I also find MZTools invaluable and in addition use SmartIndenter a free VBA add on from Office Automation limited (http://www.oaltd.co.uk/).

Finally I use Total Access Analyzer from FMS Inc (www.fmsinc.com) to check my code and identify unused functions/redundant code that I can delete if I wish. This is also a great tool for documenting projects for clients.

# March 14, 2008 6:00 AM

Charie Zhu said:

I am wondering how to use "Visual SourceSafe which allows to check in/out all the database objects". Could you help?

# March 14, 2008 9:10 AM

Rickard Olsson said:

I try to remember when I last used them, if I am lucky I also find them. In other words totally unorganized.

I wish I had the habits the guys above describe, so any help in the system making me more organized I would appreciate.

# March 14, 2008 2:03 PM

Arthur Fuller said:

I still use Code Librarian, from the A2K Developer's kit. Personally, I don't like to clutter apps with unused code, which is why I stick with Code Librarian. I have used its categories extensively, added lots and lots of new categories, and I keep a shortcut handy so that when I'm reading Access newsgroup lists and I see good code, I can grab it and immediately stick it into my library.

On the data side of things, I have a large database that I use to "inherit" forms, queries, tables and data. For example, I have lists of ISO country codes, states and provinces, Standard Industrial Categories (SIC) codes, and a list of about 5K cities in North America. I draw freely from this database whenever I start a new project. Lots of the forms are instantly reusable.

I also have a trick I use when designing forms and reports. I create one table that will never be a part of the application, that contains all the domains, as they are called in sources like Codd and Date -- all the PKs and FKs and columns that will be combo boxes and so on. I fill in every aspect of these domains (virtual columns might be a better name) -- their description, input mask, label, validation, rowsource for combos, etc. Then I can grab all the columns I need for any given table or form and plonk them onto the new table or form I'm creating and presto, all the specification details are already there, all done. Not quite inheritance in the O-O sense, but close enough.

# March 14, 2008 8:23 PM

Steve Sanderson said:

I also am a big fan of Mz tools.  it stores code snippets, allows you to insert then as well as line numbers in a couple of clicks.  It also allows you to create function and module headers and enter error handling code of your choice very quickly.  It is an amazing tool.  Also a temp database that has the basic structures you would like to reuse for forms from app to app.  I also have a db devoted to various eye candy stuff such as a form that will change color both the form and the font color as sliders are moved from 0 to 255.  Allows you to see how a form will look with all of the color and not just a tiny square.  Don't use it often, but it has been invaluable in some sitations.

# March 17, 2008 9:53 PM
New Comments to this post are disabled
Page view tracker