Instr function to get acronym (1 Viewer)

K

ks2020

Guest
Hi,
I have a list of business names ina table and wish to generate acronyms from that list: i.e. to generate "RGDC" from "Rudolph Gifts Delivery Company" by joining the first letter of every word in the record. Could you help please!
Thanks!
Kumar
 

pdx_man

Just trying to help
Local time
Yesterday, 16:24
Joined
Jan 23, 2001
Messages
1,347
Give this a try:

Code:
Public Function Acrnm(MyStr As String) As String

    Acrnm = Format(Left(MyStr, 1), ">")
    Do While InStr(MyStr, " ") <> 0
        Acrnm = Acrnm & Format(Mid(MyStr, InStr(MyStr, " ") + 1, 1), ">")
        MyStr = Mid(MyStr, InStr(MyStr, " ") + 1)
    Loop

End Function
 

Jack Cowley

Registered User.
Local time
Today, 00:24
Joined
Aug 7, 2000
Messages
2,639
pdx_man -

That is a slick bit of code! Well done!

Jack
 

pdx_man

Just trying to help
Local time
Yesterday, 16:24
Joined
Jan 23, 2001
Messages
1,347
:D LOL, Thanks. Hope y'all enjoy your Holidays! I'll be signing off for a few days.
 

Jack Cowley

Registered User.
Local time
Today, 00:24
Joined
Aug 7, 2000
Messages
2,639
You are welcome and a nice bit of code to send you on your Merry way for a few days of a well deserved break. You do deserve the break don't you? I am sure you do!

Jack
 
K

ks2020

Guest
Thanks pdx_man!

Thanks, it worked. I am a novice at this and struggled a bit to find how I could use the public function! But solved it after some T & E and placed it in a report to get what I wanted.
I am sure there are lots of people like me who'd truly wish helpful people like you good cheer all year long...
Happy Hols and Happy new Year!
--Kumar
:D :D :D
 

Jack Cowley

Registered User.
Local time
Today, 00:24
Joined
Aug 7, 2000
Messages
2,639
pdx_man wrote a nice piece of code for you that works a treat and there are a number of ways that you can use it. You can use it in a query and then base your report on the query or you can call it directly from the report. I would suggest a query as that seems the easiest to me. To use it in a query you would add something like this to the top field in a blank column in the query:

Acronym: Acrnm([NameOfFieldWithCompanyName])

Change 'NameOfFieldWithCompanyName' to the actual name of the field with the company name and you should be good to go...

Good luck with your project and a very Happy Holidays to you and yours...

Jack
 

Users who are viewing this thread

Top Bottom