function

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

Guest

I'm a novice, so please bear with me.
Got a field in my db with titles.
Ex: M.D.
D.O.
M.D., PhD.

Want just the 1st title & no punctuation. In query, created a new field to
add a "," @ end (i.e., M.D.,... D.O., ... M.D., PhD.,). Can't figure out the
function. Trying this:
Public Function OneDegree(Degree As String) As String
Dim TempString As String
TempString = ""
Do Until Mid(Degree) = ","
If Mid(Degree) = "." Then
Else
TempString = TempString & Mid(Degree)
End If
Loop
OneDegree = TempString
End Function
I keep getting error "Undefined Function 'OneDegree' in expression. Can
anyone help with the code? Using Office 2K/Access 2K.
 
If all you want if the first one with no punctuation, try this

P = InStr( Degree , ",") -1
if (P = -1) then P = Len(Degree)
OneDegree = Replace(Left(Degree, P),".", "")


Change the variable Degree per your field with the list of degrees

in this:
InStr: finds the first comma
Left : Gets the text before the comma
Replace: Replace "." per nothing

Take Care

Mauricio Silva
 
Back
Top