Insert character into string where necessary.

George-Bowyer

Registered User.
Local time
Today, 21:32
Joined
Dec 21, 2012
Messages
178
Hi.

I am looking for a piece of code that will look in a field and if it contains just one letter character, add a "." to the field after the letter.

If the field is null or already contains more then 1 character, it should be left unaltered.

Many thanks.
 
You can use the Len() function. Something like this in code

If Len(YourField) = 1 Then....

Or in a query

IIF(Len([YourField]) = 1, [YourField] & ".", [YourField])
 
presumably this is a middle name?

try
Code:
If len(me.MiddleName) = 1 then
Me.MiddleName = Me.MiddleName & "."
End If

Change the field name to yours.
 

Users who are viewing this thread

Back
Top Bottom