How to create a 3 letter handle

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a "Name" field and a "Name_Code" field on my form. I would like for
the name that is entered into the name field to automatically fill in the
name code field. I would like the first letter of the first name and the
firsttwo letters of the last name to be entered into the name code upon
update of the name field. I've tried, but am not successful. Help would be
appreciated greatly
 
Use the AfterUpdate event of LastName.
NameCode = Left(FirstName,1) & Left(LastName,2)
Hope you're not using NameCode a Key field... the chances of duplicates is
very high.
 
Thanks for your help. No, the name code is not a key field. Can you help me
with this? The entire first and last name is in one field. Can you tell me
how to extract the information from one field. Thanks...
 
Don,
As you realize now, you should always capture FirstName and LastName and
even MiddleInits in seperate fields.

Also, don't use a name like [Name]. There is a Name property in Access.
When you use [Name] in a calculated text control on a form, it will yield
the name of the form itself.
Use something like [FullName] instead.

If all your Names consist of a FirstName with a space and then a
LastName, then there is hope.
NameCode = Left(FullName, 1) & Mid(FullName, InStr(FullName, " ") +1,
2)
Given "John Smith" yields "JSm"

However, if you have FullNames like John J. Smith, the template will
fail. Perhaps if there are not too many of those you can fudge them
manually.
Suggest you add FirstName and LastName fields to your table, and break
out the FullName contents. You're call....
 
Back
Top