Hey guys I'm looking to run this query/calculated field in Access, heres what I want to do:
If(Salaries.Amount > 20000) {
If(Salaries.Amount > 30000) {
If(Salaries.Amount > 40000) {
Permits.Band = "Band 4";
} Else {
Permits.Band = "Band 3";
}
} Else {
Permits.Band = "Band 2";
}
} Else {
Permits.Band = "Band 1";
}
Salaries and Permits are tables, with another 2 tables in the DB - Cars and Staff.
Salaries/Staff are linked by Staff_ID: 1 to 1, Staff/Permits are linked by Staff_ID: 1 to 1, Permits/Cars are linked by Permit_ID: 1 to M.
Basically the "Band" field in Permits needs to be calculated depending on the staff members salary... The salary has got to be in a separate table from the staff details, hence the Salaries table...
Any ideas?
EDIT:
In response to answer 1:
SELECT Switch(Salaries.Amount > 40000, "Band 4",
Salaries.Amount > 30000, "Band 3",
Salaries.Amount > 20000, "Band 2",
True, "Band 1") AS Band
FROM (Staff INNER JOIN (Permits INNER JOIN Cars ON Permits.Perm_ID = Cars.Perm_ID) ON Staff.Staff_ID = Permits.Staff_ID) INNER JOIN Salaries ON Staff.Staff_ID = Salaries.Staff_ID;
Gives "Type mismatch in expression" when run...