Update query with a switch

mlopes1

Registered User.
Local time
Today, 04:34
Joined
Sep 4, 2002
Messages
76
Hi,

I have a question regarding an update query. I have a column called Segment that is blank for 10,000 records in table A. Table A also has a column called Prod Type. I am trying to write an update query that searches for some criteria in the Prod Type and then assigns a value to the Segment column.

I have written this before for a MakeTable query and it looks like this in the Field area of the query:

Segment: Switch([Prod Type] Like "*NA*","Natural",[Prod Type] Like "*IM*","Imitation",[Prod Type] Like "PR","Processed",[Prod Type] Like "OT","Processed")

But that was when I was creating a new table. I now want to run this on an existing table. How do I put this into an update query? I can not figure it out.... any ideas?

Thanks as always,

Marco
 
Create a new query based on this table. Under the Query menu command, select Update Query. Put the Segment field down below in your grid. In the Update To row, put in your Switch statement:

Switch([Prod Type] Like "*NA*","Natural",[Prod Type] Like "*IM*","Imitation",[Prod Type] Like "PR","Processed",[Prod Type] Like "OT","Processed")

HTH

Let me know how this worked out!
 
Sorry for long delay... your suggestion worked just as hoped.

I had to modify something slightly but it was because of a requirement change. The code itself worked. Thanks as always.

Marco
 

Users who are viewing this thread

Back
Top Bottom