Solved

How create calculated field in a table for Initials?

Posted on 2013-06-19
3
378 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
ID: 39260708
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
ID: 39260726
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
ID: 39260745
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to execute an access 2007 module from vb6 2 35
Add records to a form to a table 11 39
Filter cbo on datasheet - 11 32
Normalization of a table 19 71
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

776 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