Finger Tips said:
This worked great for one listing but when I run it as update query
for a lot of listings I get validation and violation error messages.
I looked ot the data and some of the entries in this addr field have
only partial address info for ex.
Weston, MA 05118 as opposes to the full address
1054 Falmoth Ave, Weston, MA 05118
Could that be what is causing the validation error because the data is
different and not all entries have the same amount of info to remove.
Again all I want left is the street address. Thanks
Fields with partial addresses shouldn't raise an error, so long as
there's at least one comma. But fields that are blank, or contain no
comma at all, will raise an error with that code.
You could, of course, use criteria in your update query to filter out
such records, but your example of an address containing only city,
state, and zip demonstrates a common problem with logic of this sort.
How much variation is there in the data? You could conceivably apply
two update queries with different criteria, one for when there appears
to be a full address, and another for when there isn't, like these:
UPDATE YourTable
SET [Addr] = Null
WHERE Not [Addr] Like '*,*,*'
UPDATE YourTable
SET [Addr] = Left([Addr], InStr([Addr], ",") - 1)
WHERE [Addr] Like '*,*,*'
Note that the above queries would have to be run in that order, because
each modifies the values previously in the field.
I'm assuming that you've already extracted your city, state, and zip
into separate fields, because you won't be able to extract them after
these update queries have run.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)