Public Function splitLongString(tmpStr As String, tmpPosition) As String
[COLOR=Green]'-----------------------------------------------------------------------
' A Function that will take in a Long String, and returns
' a String which is a dissected part of the String, based on the
' location that it is required of.
'
' Input : A Normal String, that needs to be broken down/split
' 1 - Name
' 2 - Telephone Number
' 3 - Address
' 4 - City
' 5 - Postcode
' Output : A String based the location number.
' Example :
' ? splitLongString("A & A Adeniran (403) " & _
' "460-2799 153 Somerset Way SW Calgary AB T2Y 3K3", 2)
' (403) 460-2799
' telNumber : splitLongString([fieldName], 2)
'
' Author : Paul Eugin, Mar 2013
'-----------------------------------------------------------------------[/COLOR]
Dim varStr As String, dumVarStr As String
tmpStr = Trim(tmpStr)
Select Case tmpPosition
Case 1
splitLongString = Trim(Left(tmpStr, InStr(tmpStr, "(") - 1))
Case 2
splitLongString = Trim(Mid(tmpStr, InStr(tmpStr, "("), 15))
Case 3
dumVarStr = Mid(StrReverse(tmpStr), Len(Left(StrReverse(tmpStr), 12)))
dumVarStr = StrReverse(Left(dumVarStr, InStr(dumVarStr, " ")))
varStr = Mid(tmpStr, Len(Left(tmpStr, InStr(tmpStr, "(") - 1)) + 15)
splitLongString = Trim(Mid(varStr, 1, InStr(varStr, dumVarStr)))
Case 4
varStr = Mid(StrReverse(tmpStr), Len(Left(StrReverse(tmpStr), 12)))
splitLongString = Trim(StrReverse(Left(varStr, InStr(varStr, " "))))
Case 5
splitLongString = Trim(Right(tmpStr, 7))
Case Else
splitLongString = "N/A"
End Select
End Function