Given the vast inconsistencies in addresses, that this is going to be
potentially inaccurate.
For most addresses, this little UDF might suffice:
*****************************************************************
Function ySplit(ByVal pTarget As String, _
pItem As String, _
Optional ShowLeft As Boolean = True) _
As String
'*******************************************
'Purpose: Splits a string to the left or
' right of pItem
'Coded by: raskew
'Inputs: 1) ySplit("The quick+ brown fox", "+", True)
' 2) ySplit("The quick+ brown fox", "+", False)
'Output: 1) The quick
' 2) brown fox
'*******************************************
Dim strLeft As String
Dim strRight As String
Dim n As Integer
n = InStr(pTarget, pItem)
If n = 0 Then
ySplit = ""
Else
ShowLeft = IIf(IsMissing(ShowLeft), True, ShowLeft)
strLeft = Left(pTarget, n - 1)
strRight = Mid(pTarget, n + 1)
ySplit = Trim(IIf(ShowLeft, strLeft, strRight))
End If
End Function
*****************************************************************
Examples from the immediate (debug) window:
x = "106-20A 20th Avenue"
? ysplit(x, " ", True)
106-20A
? ysplit(x, " ", False)
20th Avenue
Where this would fail, however, is with an address like:
106-20A Apt. 2C 20th Avenue
You may want to look at the split() function.
Bob
bird said:
My bad. My request was unclear. There are a number of records, each with
an
address, [address]i.e. 125 Main Street, 14 East 14th Street. I want to
update into field [streetname] just the streetname, i.le. Main Street,
Howard
Ave., so I can sort on streetname. I'd like to stick to access. Sorry,
Aaron for not being adequately specific.
I'd get a real 'address verification' solution.. for example I've been
evaluating these for my employer.
[quoted text clipped - 14 lines]
I use access 2003, and don't know programming. If you can provide
sample
syntax for an update or other type query, same would be appreciated.