Solved

How create calculated field in a table for Initials?

Posted on 2013-06-19
3
374 Views
Last Modified: 2013-06-20
I have a table and in the table I want to create a calculated field.  Also in the table is a "CompanyName" field.  If the user types "Anderson Smith & Johnson" I want the calculated field to display "AS&J".

Can this be done?  If so, what is the expression for the calculation?
0
Comment
Question by:SteveL13
  • 2
3 Comments
 
LVL 28

Expert Comment

by:omgang
Comment Utility
You really shouldn't be saving the calculated value to the table.  It's better to recalculate the value when needed in a query, form, report, etc.  In this way, if the name changes the calculated value will be changed as well.

As for the calculation itself......please hold.
OM Gang
0
 
LVL 1

Accepted Solution

by:
RCWade earned 250 total points
Comment Utility
I use the following function in Excel to get initials. It's no elegant, but it works. You should be able to fit it in your Access project easy enough.

Public Function Initials(strData As String)
Dim temp As Variant
Dim x As Variant
Dim newName As String
Dim newInitials As String

newInitials = ""
temp = Split(strData, " ")
For Each x In temp
    newInitials = newInitials & Left(x, 1)
Next

Initials = newInitials

End Function

Hope it helps.
0
 
LVL 28

Assisted Solution

by:omgang
omgang earned 250 total points
Comment Utility
To use the function provided by RCWade, in a query or ControlSource of a form/report control you could

Query column
Init:Initials([CompanyName])

Form/Report Control ControlSource
=Initials([CompanyName])

OM Gang
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now