Initials

G

Guest

I have a field where a title can be entered.

If the entry looks like: "On Job Training" (without quotes) then I would
like the next field to show it as OJT.

Could someone provide me with a module that would accomplish this for me?

Thanks in advance for your assistance.

Rick
 
R

Ron Weiner

Rick

**** Air Code ****

Function Acronymizer(strIn as string) as string
dim a() as string, i as integer
a = split(strIn, " ")
for i = lbound(a) to ubound(a)
Acronymizer = Acronymizer & ucase(left(a(i),1))
next
end function

You could use it in the after update event of the txtFullName Field
me.txtAcronym = Acronymizer(me.txtFullName)

Ron W
www.WorksRite.com
 
G

Guest

Hi Ron:

Your code works great. I actually made it into the Public Function Module so
that it will work in a report.

I'm wondering if you could make it do one more thing. This will be a
challenge. One of the names is hyphenated (Miami-Dade Community College) and
as a result I get MCC in stead of MDCC.

Thanks for your help in advance.

Rick
 
R

Ron Weiner

Rick

Just add another inner loop like this:

Function Acronymizer(strIn as string) as string
dim a() as string, b() as string, i as integer, j as integer
a = split(strIn, " ")
for i = lbound(a) to ubound(a)
b = split(a(i) "-")
for j = lbound(b) to ubound(b)
Acronymizer = Acronymizer & ucase(left(b(i),1))
next
next
end function


BUT I gota' tell you just because you can do something doesn't mean that you
should. I think is this a really bad idea, as it might on occasion come up
with acronym's that spell words that might be considered -- well poor taste!
Consider.

foreign undersecretary concerning killing errant rats
or
Secretary human interest topics
or
public interest special services
or

Well you get it. If it were me I would insist that the human doing the data
entry create the acronym.

Ron W
www.WorksRite.com
 
G

Guest

Thanks Ron...

I played with a couple of loops "of", "the", "." and it's working nicely as
a module.
I fully understand what you mean about letting them enter their own
acronyms. Unfortunately I cannot add any more fields to the data side since
they have distributed the program to quite a few locations. I literally have
to take their agency name and make the best of it.

Again... thanks... You were very helpful.

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top