Replace text in query field

clintthorn

Registered User.
Local time
Yesterday, 17:39
Joined
Jul 2, 2008
Messages
16
I have 2 fields that are related (Distcode and Prevcode). All rows of data have distcode and prevcode values. However, so of the Prevcode values are 'UNK'. When this is the case, their value should actually equal the value in the distcode field.

I know in Excel this would be a simple 'IF' formula, but I do not know how to replicate this in Access.

Any tips?

Below is the Query's SQL:
SELECT Month([Date]) AS [Month], DLP_Data_Table.Date, DLP_Data_Table.Source, DLP_Data_Table.Client, DLP_Data_Table.Prodcode, DLP_Data_Table.Offercode, DLP_Data_Table.Lang, DLP_Data_Table.Distcode, DLP_Data_Table.Prevcode, DLP_Data_Table.Country, DLP_Data_Table.Presented, DLP_Data_Table.Accepted, DLP_Data_Table.Installed, Brandcode_Table.Product, Bucket_Table.DISTRIBUTION, Bucket_Table.BUCKETS, Bucket_Table.[RP Version], Geo_Table.Geo
FROM (Geo_Table RIGHT JOIN (DLP_Data_Table LEFT JOIN Bucket_Table ON DLP_Data_Table.Distcode=Bucket_Table.DISTCODE) ON Geo_Table.[2 digit]=DLP_Data_Table.Country) LEFT JOIN Brandcode_Table ON DLP_Data_Table.Offercode=Brandcode_Table.Offer;
 
IIf(Prevcode = "UNK", distcode, Prevcode)
 
I cannot get it to work. The query I have is a select query. Do I need to create a separate query to do this? Or just put the code in a specific place?

Thanks for the help.
 
That would be a new field. In design view:

CombinedField: IIf(Prevcode = "UNK", distcode, Prevcode)
 

Users who are viewing this thread

Back
Top Bottom