View Full Version : Changing Specific Text in a Query


Derek O'Brien
07-22-2009, 05:49 AM
I'm hoping someone can help me with what I'm sure is a basic question.

I'm using Microsoft Access 2003, and I trying to create a query involving names and addresses. there is a separate field for the postcodes. There is a specific postcode which I need to amend using the query, but the two methods I've tried are less than perfect.

In the first instance, if I use:
Replace([Prof Inv].[Address Postcode],'OL16 5RX','OL16 5RS') AS Postcode
It does change the postcodes, leaves the others - but produces "#Error" in records where there was never any postcode listed.

In the second instance, if I use:
Iif([Prof Inv].[Address Postcode]='OL16 5RX','OL16 5RS') AS Postcode
It does change the postcodes, but wipes out all the others.

Where am I going wrong, please?

Many thanks in advance,

Derek

DCrake
07-22-2009, 06:08 AM
You need an update query which would read something like this


Update [Prof Inv] Set [Address Postcode] ='OL16 5RS' Where [Address Postcode]='OL16 5RX'

David

Derek O'Brien
07-22-2009, 07:06 AM
That worked - many thanks for the quick reply, David! :-)