Using MS Access 2003, I am working on a project management database and have reached the point where I need to develop a way for managers to re-assign responsibility for all active projects to another of his/her resources.
The Field names for the different managers associated with each project are:
[EngMgr] [ProdProcMgr] [MfgMgr] [QAMgr] [MatMgr]
When a new project is entered each manager assigns a resource to a related Resource field as follows:
[EngMgr] assigns a person to Resource field [ProjMgr]
[ProdProcMgr] assigns a person to Resource field [ProdProcRep]
[MfgMgr] assigns a person to Resource field [MfgRep]
[QAMgr] assigns a person to Resource field [QARep]
and [MatMgr] assigns a person to Resource field to [MatRep].
There are multiple manager names possible for each Manager Field and multiple resource names possible for each Resource Field
I have a routine that replaces the resource for a single project which works fine but now I need to replace the assigned resource in every project where the vacating resource appears.
The problem I have is this: An assigned resource leaves the company and all active projects assigned to this resource must be reassigned.
I am capturing the username of the database user (CurrentUser) who is attempting to re-assign a resource for all projects and comparing it against a table containing all manager names so I can restrict this function to allow managers to re-assign only his/her resources. Once I verify the user is a manager, I prompt for the name of the resource to be replaced (OldResource) and the resource to replace with (NewResource).
Once I have (OldResource) and (NewResource) captured I need to run an update query or some other database wizardry on the PAR Table that will do the following:
Update [ProjMgr] to (NewResource) Where [EngMgr] = (CurrentUser)
Or Update [ProdProcRep] to (NewResource) Where [ProdProcMgr] = (CurrentUser)
Or Update [MfgRep] to (NewResource) Where [MfgMgr] = (CurrentUser)
Or Update [QARep] to (NewResource) Where [QAMgr] = (CurrentUser)
Or Update [MatRep] to (NewResource) Where [MatMgr] = (CurrentUser)
I can do this with 5 sequential update queries as shown below four that would do nothing and one that would (when criteria are met), just looking to expand my apparent lack of knowledge about queries.
I was hoping to learn more about using select case statements inside an SQL statement. So I could have one query to execute no matter who is using the database and so I don’t have to loop through a recordset. Also, I am just looking to expand my apparent lack of knowledge about queries.
These five statements do what I need but, would like to know if it can be done in one. Note: Line continuation characters are missing and FLD = CurrentUser
Expand|Select|Wrap|Line Numbers
- CurrentDb.Execute "UPDATE PAR SET PAR.ProjMgr = '" & NewResource & "'
- WHERE PAR.EngMgr='" & FLD & "' AND PAR.ProjMgr='" & OldResource & "';"
- CurrentDb.Execute "UPDATE PAR SET PAR.ProdProcRep = '" & NewResource & "'
- WHERE PAR.ProdProcMgr='" & FLD & "' AND PAR.ProdProcRep='" & OldResource & "';"
- CurrentDb.Execute "UPDATE PAR SET PAR.MfgRep = '" & NewResource & "'
- WHERE PAR.MfgMgr='" & FLD & "' AND PAR.MfgRep='" & OldResource & "';"
- CurrentDb.Execute "UPDATE PAR SET PAR.QARep = '" & NewResource & "'
- WHERE PAR.QAMgr='" & FLD & "' AND PAR.QARep='" & OldResource & "';"
- CurrentDb.Execute "UPDATE PAR SET PAR.MatRep = '" & NewResource & "'
- WHERE PAR.MatMgr='" & FLD & "' AND PAR.MatRep='" & OldResource & "';"
Thanks in advance for any guidance/help,
Jeff