I have a table with the following information on it:
ID Number; Part Department; Truck Number
Each ID has one of 3 Part Departments, E, P, or H. There are several ID numbers associated with each Truck number. Here's a sample of my data:
The pink and purple shaded areas are both from Truck 13. As you can see, the pink lines are all Part Department "H", and the purple ones are Part Department "P".
Now for the fun part. I can't figure out how to make the following to happen...
If ANY ID within a truck number is Part Department H, all of the IDs on the entire truck need to be counted as H.
IE, even though 7 of the IDs on Truck 13 are from Department P, those seven need to be counted as H since there is at least one ID from Department H on that truck. (If there were NO IDs from department H, then each ID would keep its original Department letter.)
I THINK I need to use a Dcount function in a new query to get the result I want, but... I've been struggling with it.
NOTE: I *can* get the result I'm looking for in Excel with the Countifs function. It lets you use 2 criterion, so I can say,
=IF(COUNTIFS({Truck},{Whichever truck this line is},{Department},{"H"})>0,"H",{Whichever Department this line is}).
It's literally =IF(COUNTIFS(E:E,E2003,C:C,"H")>0,"H",C2003).
Now I just need to figure out how to get the same result in a query in Access.
Any help would be greatly appreciated! Thanks!
ID Number; Part Department; Truck Number
Each ID has one of 3 Part Departments, E, P, or H. There are several ID numbers associated with each Truck number. Here's a sample of my data:
The pink and purple shaded areas are both from Truck 13. As you can see, the pink lines are all Part Department "H", and the purple ones are Part Department "P".
Now for the fun part. I can't figure out how to make the following to happen...
If ANY ID within a truck number is Part Department H, all of the IDs on the entire truck need to be counted as H.
IE, even though 7 of the IDs on Truck 13 are from Department P, those seven need to be counted as H since there is at least one ID from Department H on that truck. (If there were NO IDs from department H, then each ID would keep its original Department letter.)
I THINK I need to use a Dcount function in a new query to get the result I want, but... I've been struggling with it.
NOTE: I *can* get the result I'm looking for in Excel with the Countifs function. It lets you use 2 criterion, so I can say,
=IF(COUNTIFS({Truck},{Whichever truck this line is},{Department},{"H"})>0,"H",{Whichever Department this line is}).
It's literally =IF(COUNTIFS(E:E,E2003,C:C,"H")>0,"H",C2003).
Now I just need to figure out how to get the same result in a query in Access.
Any help would be greatly appreciated! Thanks!
Last edited: