String Function

  • Thread starter Thread starter Mark K
  • Start date Start date
M

Mark K

I'm trying to create a function to use in a query
expression that will go through a field list to break down
a string in order to retrieve the common suffixes of the
string.

Here is an example string list:

IGS-NASFRONTED
NAS-FRONTEND
IGS-NASBACKEND
NAS-BACKEND
IGS-NASFINANCE
NAS-FINANCE

My desire result would be:

FRONTEND
FRONTEND
BACKEND
BACKEND
FINANCE
FINANCE

Here is what I have so far but it will give me a compile
error.

Function newBucket(StrGroupID As String) As String

Dim StrCutPrefix As String
Dim StrTemp As String
Dim StrBucket As String

If IsNull(StrGroupID) Then
StrBucket = ""
Exit Function
End If

StrCutPrefix = Mid(StrGroupID, 5)
StrTemp = Left(StrCutPrefix, 3)


If StrTemp = "NAS" Then
StrBucket = Mid(StrCutPrefix, 4)
Else
StrBucket = StrCutPrefix
End If

newBucket = StrBucket

End Function

Any help will be greatly appreciated. Thank You.
 
What is the compile error?

--
HTH,

Steve Clark, Access MVP
FMS, Inc.
Professional Solutions Group
http://www.FMSInc.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Is your Access database too slow?
Are you ready to upgrade to SQL Server?
Contact us for optimization and/or upsizing!
http://www.FMSInc.com/consulting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
I receive a "Compile Error: Expected variable or
procedure, not module" when I test it in the Immediate
Window. I also get 'Undefined function 'newBucket' in
expression when I run it in the query. How can I make this
run correclty?

Mark
 
Back
Top