Sharlee
.com
MS Access Database Programming

HOME     BACK

Function ProperString
A function for automatic capitalization of proper words.
For MS Access 97/2000

This code can be applied to any text field to create automatic capitalization
of the first letter of each word entered to that field.

Example: mary b. stevens will be automatically updated to Mary B. Stevens

The code works with a table called u_PROPER_WORDS, which is used to collect proper
names that should not be converted. The code looks in this table and finds any
match. If it finds a match it uses the entry in the table rather than converting
only the first letter of the proper word found.

Example: macdonald would be found in the table and converted to its entry: MacDonald

Users can add new proper names to the table by pressing CTRL + A. This pops up an
input box into which they can enter the word to the table in its properly spelled form.

This code is intended for use in Microsoft Access 97/2000. It may not run properly in
earlier versions. Microsoft DAO 3.6 Object Library must be set as a Reference in the
database modules settings.

A) How to Add the Code to Your Database:

1. Make a new general module.
2. Copy the code in the window that follows to your new general module

   Note: You will add this code only once to each database you want to use it in.

3. Create a new table in your database and name it u_PROPER_WORDS.
      a. Add a text field to the table
      b. Name the field: PROPER_WORD


B) How To Set up Your Form to Use the Code:

1. Set the form's Key Preview Event to Yes
2. Copy the following code to the form's On Key Down Event

   Note: You will need to add this code to each form you want to use it in.

C) How To Use the Code on Individual Fields

1. Copy the code that follows to the AfterUpdate event of the field you want to use it on.
    Note: You will need to replace the word "LAST" with whatever the actual name of your field is.
2. Teach your users how to use the function. You might want to create a utility form for
    your users to edit the Proper Words table in case of user errors that produce unwanted
    entries to the table.

NOTICE:

Please include the Copyright and General Public License notice section in your
general module. Here is the web address for the license: GNU General Public License.

If you are not familiar with this license, you should read it before you implement
this code into your database. Since you are a programmer, you should read it anyway
so you can use it if you need to for your own code!



TOP     HOME     BACK