How do I correct spelling after typing

J

Jwibbie

I am working in Access 2003 with names and addresses. The states are
abbreviated with 2 characters. I would like to be able to fix the
abbreviations with CAPS. Some of them are as follows: Mo, Il, Mn, and I want
MO, IL, MN. Please help. Have tried the auto correct, but have not been
successful. Thanks.
 
S

scubadiver

There is a method for converting to uppercase but you haven't stated where
the abbreviations are to be more specific.
 
K

Ken Sheridan

You can convert input to upper case as its typed into a control by putting
the following in the control's KeyPress event procedure:

Dim strCharacter As String

' Convert ANSI value to character string.
strCharacter = Chr(KeyAscii)
' Convert character to upper case, then to ANSI value.
KeyAscii = Asc(UCase(strCharacter))

You can convert any existing data to upper case by means of an update query
e.g.

UPDATE Addresses
SET State = UCASE(State)
WHERE State IS NOT NULL;

However to ensure data integrity you should really have a separate table
States with a column State defined as its primary key. The abbreviations for
all states would be entered into this column in advance (use the above code
for the KeyPress event of the State control in the form bound to the States
table to force the input to upper case). You can add another column for the
full name of the state if you wish.

In a form bound to your main addresses table you can then bind the State
column to a combo box with a RowSource of:

SELECT State FROM States ORDER BY State;

and its LimitToList property set to true (Yes in the properties sheet). The
user can then select the state from the list with the mouse or by entering
the characters (ensure the control's AutoExpand property is set to True) and
the control will go to the first match as each character is entered.

To muddy the waters further, however, if you have columns for both City and
State for instance in the main addresses you are introducing redundancy as
the State is determined by the City, so you should only have a CityID column,
a unique number not the city name as city names are duplicated, which will
reference the primary key CityID of a Cities table which in turn will
reference the States table. Update anomalies which could result in an
address being entered with a city in the wrong state are thus avoided. With
this normalized structure you can still select the state first then select
from a list of cities in that state if you wish, by using an unbound combo
box for the state. You'll find a demo of how to handle this sort of data
(using the local administrative areas in my location) at:


http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=23626&webtag=ws-msdevapps


Ken Sheridan
Stafford, England
 
J

John W. Vinson

I am working in Access 2003 with names and addresses. The states are
abbreviated with 2 characters. I would like to be able to fix the
abbreviations with CAPS. Some of them are as follows: Mo, Il, Mn, and I want
MO, IL, MN. Please help. Have tried the auto correct, but have not been
successful. Thanks.

That can be a real problem: if your address field contains (say) "2118
Indianola Drive, Indianapolis, In" and you do a simple replace, you'll get
"2118 INdianola Drive, INdianapolis, IN". This is one reason to consider
having separate fields for address number, street, city, state, and postcode!

Could you post some examples of the data that you actually have in the field?
It may be necessary to get some third-party "Regular Expression" tools to do
the editing.

John W. Vinson [MVP]
 
Top