This query may be absolutely ridiculous or maybe I just have one little thing wrong. I’m not quite sure. But basically I’m trying to update a table with data from another table in Access. The columns that are giving me issues are those set to “Yes/No” types and the data I’m trying to update it with are set to “Text” types whose values are strings “Yes” or “No.”
So what I had in mind with this query, if it’s even possible, is to roughly convert it the “Text” fields to 1’s or 0’s depending on their Yes or No values, respectively. Anyway, enough background, here’s the query:
UPDATE Group_Pricing SET
Contract_Type = (SELECT Contract_Type FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID),
Hybrid_Retail =
(SELECT CASE (SELECT RetailSpread FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID)
CASE "Yes"
RetailSpread = 1
CASE "No"
RetailSpread = 0),
Hybrid_Mail =
(SELECT CASE (SELECT MailSpread FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID)
CASE "Yes"
MailSpread = 1
CASE "No"
MailSpread = 0),
Hybrid_Specialty =
(SELECT CASE (SELECT SpecialtySpread FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID)
CASE "Yes"
SpecialtySpread = 1
CASE "No"
SpecialtySpread = 0),
Hybrid_Rebates =
(SELECT CASE (SELECT Rebates FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID)
CASE "Yes"
Rebates = 1
CASE "No"
Rebates = 0)
WHERE EXISTS (SELECT 1 FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID);
Any help is much appreciated. If this is impossible, just tell me I’m an idiot. Thanks!
You cannot have CASE in MS Access, you can have IIf.
Note that YesNo in MS Access is -1 and 0
It would be much easier, however, to just say:
EDIT
This
(RetailSpread="Yes")will evaluate toTrue(-1)