I'm trying to write an update query that will link records between two tables depending on whether an integer value derived from one table falls between the values of two integer values from the other table.
I have a Members table, and a Rates table. The Members table has DOB. The Rates table has a MIN_AGE and a MAX_AGE. For each record in the Members table, I want to calculate each member's age based on the current date at runtime, then match each Members record to a Rates record where the Member's age falls into the range between the Rates record's MIN_AGE and MAX_AGE records.
Here are a couple of failed attempts I made:
Attempt 1 using subquery
Access says "Operation must use an updateable query."
Attempt 2 using inner join
Access says "Syntax error (missing operator)..."
I can't find much help online for this sort of problem. Maybe I'm approaching this all wrong?
I have a Members table, and a Rates table. The Members table has DOB. The Rates table has a MIN_AGE and a MAX_AGE. For each record in the Members table, I want to calculate each member's age based on the current date at runtime, then match each Members record to a Rates record where the Member's age falls into the range between the Rates record's MIN_AGE and MAX_AGE records.
Here are a couple of failed attempts I made:
Attempt 1 using subquery
SQL:
UPDATE Members
SET Members.RATE_FK = (SELECT ID FROM Rates WHERE (DATEDIFF('yyyy', DATE(), Members.DOB) BETWEEN Rates.MIN_AGE AND Rates.MAX_AGE))
WHERE Members.ACTIVE = 'Yes';
Access says "Operation must use an updateable query."
Attempt 2 using inner join
SQL:
UPDATE Members
SET Members.RATE_FK = Rates.ID
FROM Members
INNER JOIN Rates ON DATEDIFF(year, DATE(), Members.DOB) BETWEEN Rates.MIN_AGE AND Rates.MAX_AGE
WHERE Members.ACTIVE = 'Yes';
Access says "Syntax error (missing operator)..."
I can't find much help online for this sort of problem. Maybe I'm approaching this all wrong?