troubleshooting Question

Access 2016 Query with Proper Case logic

Avatar of E C
E CFlag for United States of America asked on
DatabasesMicrosoft AccessMongoDB* data analysis
2 Comments1 Solution319 ViewsLast Modified:
I am using Access 2016 to import a CSV file, format the data and then export a new CSV.

(The exported CSV must have data in specific columns and specific formats, so that it can be uploaded to the back end of a web app)

Some of the formatting is easy. For example, the web app requires a field called "Address3" to be in column 9.
The data that I am importing will never have an Address 3 field, so in my select query in Access, I just use this expression:
     "" AS Address3

To make sure there are no leading/trailing spaces in my records, I can do something like this:
    Trim(LocationList.City) AS City

The Address fields (Address 1, Address 2 and City) in the source file are always UPPER CASE.
But I need them to be proper case. So I use this expressing in my Access Select Query:
        StrConv(LocationList.Address1,3) AS Address1

This works great, except some parts of the address should NOT be converted to Proper Case.

An example:
    1234 MAIN STREET SW
should be converted to
    1234 Main Street SW  (Not "Sw")

There are a finite number of combinations that should remain in all caps - mainly the directional abbreviations:  NE, SE, SW, NW and perhaps a few more.

Is it possible to write a select Query in Access that does this:
    Convert this field to Proper Case, but leave "NE", "SE", "SW" and "NW" capitalized
And to make it more complicated, only apply this when these combinations of letters stand alone. In other words, either a space before and after or a space before and end of line after, or beginning of line before and a space after.  In other words, "NEWTON" should still convert to "Newton", not "NEwton"

Or maybe a Select Query is not the right place to do this. Maybe when I run the query, it can trigger some code that iterates through each word in the field, and then the information is displayed?

The entire purpose of this Access database is to transform the source data into a specific format, so that it can be exported as a new csv file and uploaded to a different (third party) web application.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros