Code:
SELECT HVVMG.Providers, [Doctor-Patient Communication] as DP_comm,[Office Staff] as off,[Continuity and Coordination of Care] as coord_of_care,HVVMG.[Overall Ratings - Provider] as Overall, HVVMG.[Timely Access to Care] As Access, HVVMG.Respondents,HVVMG.Facilities as fac, HVVMG.all_ques_avg,HVVMG.all_ques_avg_rank,HVVMG.MTC_75,HVVMG.MTC_90 FROM HVVMG Where fnLastname([Providers]) = "ALTAYS" AND FnfirstName([Providers]) = "MIKE";
'Functions
Public Function fnlastname(ByVal strname As String) As String
Dim tmpstr As String
tmpstr = Left(strname, InStr(1, strname, ",") - 1)
If Right(tmpstr, 4) = "M.D." Then
tmpstr = Left(tmpstr, Len(tmpstr) - 4)
End If
fnlastname = tmpstr
End Function
Public Function fnfirstname(ByVal strname As String) As String
Dim tmpstr As String, lngfirstcomma As Long, lngsecondcomma As Long
tmpstr = Right(strname, Len(strname) - InStr(1, strname, ","))
Select Case Left(tmpstr, 4)
Case Is = " DO ", Is = " MD "
tmpstr = Right(tmpstr, Len(tmpstr) - 4)
Case Is = " M.D", Is = " MD,", Is = " DO,", Is = " D.O", Is = "MD (", Is = "(PCP"
lngfirstcomma = InStr(1, tmpstr, ",")
lngsecondcomma = InStr(lngfirstcomma, tmpstr, ",")
tmpstr = Right(tmpstr, Len(tmpstr) - lngsecondcomma)
End Select
tmpstr = Trim(tmpstr)
If Left(tmpstr, 5) = "(PCP)" Then
tmpstr = Right(tmpstr, Len(tmpstr) - 6)
End If
If InStr(1, tmpstr, " ") > 0 Then
fnfirstname = Left(tmpstr, InStr(1, tmpstr, " ") - 1)
Else
fnfirstname = tmpstr
End If
End Function