jpjordan357
New member
- Local time
- Yesterday, 18:41
- Joined
- Jan 19, 2022
- Messages
- 12
Good morning, everyone. Here's what I have going on.
I'm building a database that, among other things, contains an employee database. Aside from the usual first name, last name, username, etc, we have employee roles, which is one of my records that needs to be searched, as well as location. I am trying to populate a 'Manager' field based on the 'Managing Role' field. I have a query that weeds out managers to use as a source lookup. The reason i do this, is that the Manager changes, but the Managing Role doesn't, therefore when a manager changes (say, an IT manager), the query will always display who holds that position. For the most part, this works fine; because all but 9 of the 'ManagingRoles' are unique (Corporate Level). The problem i'm running into is the other 9. they all hold the same title but for different locations. So i'm trying to make two things:
1) A lookup field that will look at the location i've set for the employee, the managing role, and then select the appropriate name from a query that has the list of location managers.
2) An IIF statement for the query to pick the correct 'calculation', as it were. I believe I have this part already figured out, but since i can't figure out #1, this one doesn't work.
Here's what I have so far. My dlookup expression for returning a Manager field:
DLookUp("[qryManagement]![ProperName]","qryManagement"," [qryManagement]![RoleName] ='" & [ManagingRole] & "'"))
qryManagement is my query that filters out managers, ProperName is just the expression field within that combines FirstName and LastName into Last, First.
RoleName is the check value in the management query, and then ManagingRole is what checks against RoleName. This works every time:
This works great, except for, as I mentioned, the branch manager role. as you can more or less see above, record 10 and 14 hold have the same managing roles, but they are at different locations, so record 10's manager should show as record 9's name (as it does), and record 15's manager should show as record 13's name, because they are at the same location. I tried to accomplish this with the following expression, but no matter what I do, record 9's name always comes back as 'Manager' for the 'Branch Manager' managing role:
DLookUp("[qryBranchManagers]![ProperName]","qryBranchManagers"," [qryBranchManagers]![Role]='" & [ManagingRole] & "'" And "[qryBranchManagers]![Location] ='" & [Location] & "'")
The above references qryBranchManagers which filters out only those active employees with the branch manager roles and their locations. However, whenever I do this, anyone with the 'Branch Manager' set as their 'Managing Role', Record 9's name populates as the manager, probably because it shows up first in the table alphabetically. I've looked long and hard and haven't been able to quite find a solution to this around this forum or various others.
Finally, using both of those dlookup expressions, i've created the following IIF expression, which works, but only kind of because of the 'branch manager' thing not working:
Manager: IIf([managingrole]="Branch Manager",DLookUp("[qryBranchManagers]![ProperName]","qryBranchManagers"," [qryBranchManagers]![Role]='" & [ManagingRole] & "'" And "[qryBranchManagers]![Location] ='" & [Location] & "'"),DLookUp("[qryManagement]![ProperName]","qryManagement"," [qryManagement]![RoleName] ='" & [ManagingRole] & "'"))
Perhaps its something simple, perhaps there's an easier way of doing this that i've overlooked? I'd appreciate any help someone can provide, and thank you in advance!
I'm building a database that, among other things, contains an employee database. Aside from the usual first name, last name, username, etc, we have employee roles, which is one of my records that needs to be searched, as well as location. I am trying to populate a 'Manager' field based on the 'Managing Role' field. I have a query that weeds out managers to use as a source lookup. The reason i do this, is that the Manager changes, but the Managing Role doesn't, therefore when a manager changes (say, an IT manager), the query will always display who holds that position. For the most part, this works fine; because all but 9 of the 'ManagingRoles' are unique (Corporate Level). The problem i'm running into is the other 9. they all hold the same title but for different locations. So i'm trying to make two things:
1) A lookup field that will look at the location i've set for the employee, the managing role, and then select the appropriate name from a query that has the list of location managers.
2) An IIF statement for the query to pick the correct 'calculation', as it were. I believe I have this part already figured out, but since i can't figure out #1, this one doesn't work.
Here's what I have so far. My dlookup expression for returning a Manager field:
DLookUp("[qryManagement]![ProperName]","qryManagement"," [qryManagement]![RoleName] ='" & [ManagingRole] & "'"))
qryManagement is my query that filters out managers, ProperName is just the expression field within that combines FirstName and LastName into Last, First.
RoleName is the check value in the management query, and then ManagingRole is what checks against RoleName. This works every time:
This works great, except for, as I mentioned, the branch manager role. as you can more or less see above, record 10 and 14 hold have the same managing roles, but they are at different locations, so record 10's manager should show as record 9's name (as it does), and record 15's manager should show as record 13's name, because they are at the same location. I tried to accomplish this with the following expression, but no matter what I do, record 9's name always comes back as 'Manager' for the 'Branch Manager' managing role:
DLookUp("[qryBranchManagers]![ProperName]","qryBranchManagers"," [qryBranchManagers]![Role]='" & [ManagingRole] & "'" And "[qryBranchManagers]![Location] ='" & [Location] & "'")
The above references qryBranchManagers which filters out only those active employees with the branch manager roles and their locations. However, whenever I do this, anyone with the 'Branch Manager' set as their 'Managing Role', Record 9's name populates as the manager, probably because it shows up first in the table alphabetically. I've looked long and hard and haven't been able to quite find a solution to this around this forum or various others.
Finally, using both of those dlookup expressions, i've created the following IIF expression, which works, but only kind of because of the 'branch manager' thing not working:
Manager: IIf([managingrole]="Branch Manager",DLookUp("[qryBranchManagers]![ProperName]","qryBranchManagers"," [qryBranchManagers]![Role]='" & [ManagingRole] & "'" And "[qryBranchManagers]![Location] ='" & [Location] & "'"),DLookUp("[qryManagement]![ProperName]","qryManagement"," [qryManagement]![RoleName] ='" & [ManagingRole] & "'"))
Perhaps its something simple, perhaps there's an easier way of doing this that i've overlooked? I'd appreciate any help someone can provide, and thank you in advance!