if not use join

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a query "select departmentnumber from employee." I don't want to join
the employee table to the department table, instead, I want to add something
to the select query like "if departmentnumber = 1 then 'IT' else 'Marketing'
end if.
In Access, is that possible?

Thanks.
 
I have a query "select departmentnumber from employee." I don't want to join
the employee table to the department table, instead, I want to add something
to the select query like "if departmentnumber = 1 then 'IT' else 'Marketing'
end if.
In Access, is that possible?

A couple of ways; if it's just the two choices use the IIF (Immediate
If) function:

DeptName: IIF([departmentnumber] = 1, "IT", "Marketing")

For multichoices use the Choose() function:

DeptName: Choose([departmentnumber], "IT", "Marketing", "Human
Resources", "Research")

Or use DLookUp to find the value in the Departments table without
linking it:

DeptName: DLookUp("[DepartmentName]", "[Department]",
"[Departmentnumber] = " & [departmentnumber])


John W. Vinson[MVP]
(no longer chatting for now)
 
Back
Top