Using MS Access/Multiple if statements

Advertisement


Question
I created a database in access to track vehicle mileage. One field has users enter a department number. I need to show in my report which agency the department falls under. Is there a way to write a if,then type statement to automatically assign an agency number to each department. I have 590 departments in 31 agencies. I was trying to use =IIf([Department #]=800,1) {1 is the agency #} but I cant seem to figure out how to add more department #'s if that is even possible.
Thanks for your help
B

Answer
You need more tables. You need An Agency table and you need to an Agency field in your departments table.

tblAgencies
AgencyID (Primary key-Autonumber)
AgencyName

tblDepartments
DepartmentID (PK Autonumber)
DepartmentName
AgencyID (Foreign key to tblAgencies)

With that structure you can join your tables to get Agency Name for reporting purposes.

HTH
Scott<>

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

©2012 About.com, a part of The New York Times Company. All rights reserved.