figment222
New Member
- Joined
- Mar 6, 2015
- Messages
- 48
Hello, i'm kinda new to access, so excuse me if my problem here is poorly-worded.
I have a form that tracks Jobs and a subform that tracks various items for each Job and the status for each: Completed, elapsed minutes, etc. Each item might require additional Processes and I want to know how long it took for each item as they are completed. So, essentially, I want a subtotal for each item, which includes how long each of of the processes took.
The subform is fed by a query called "qry_MetalsItemsActive" with a field for the time it takes to complete a process. Each process has a unique ID. When a process is part of a larger assembly, we have a field called ParentID, which will be equal to whatever the ID was of the parent.
An example:
Record1, ID=1, ParentID=Null
Record2, ID=2, ParentID=1
Record2, ID=3, ParentID=1
unfortunately, the creator of this table only populated the ID in the ParentID field if it was not the Parent, so some are blank and some are not. I've used this to identify blanks as Parent records and non-blanks as child records.
So, I created a new field in the main query called AssyID: IIf(IsNull([ParentID]),[ID],[ParentID])
So, in my example
Record1, ID=1, ParentID=Null, AssyID=1, minutes=20
Record2, ID=2, ParentID=1, AssyID=1, minutes=30
Record2, ID=3, ParentID=1, AssyID=1, minutes=10
Now, I can sort by this field in the subform datasheet view and see each record and identify the ones that are part of the same assembly, without grouping them together. BUT, I still only see how long each record took, NOT a subtotal of 60 minutes.
I want another field that tells me the subtotal for the assembly: 60 minutes
Then, I created another query called "qry_MetalsItems_MinPerAssy", where I group by the AssyID and then created a calculated field:
MinPerAssy: Sum([ElapsedTimeEach]/[quantity])
This works well to give me how many minutes it took for each assembly.
My problem is that I can't seem to bring this field BACK into the query that feeds my subform. I open my qry in DES view and add the new qry with the MinPerAssy field, but when I try to INNERJOIN, it tells me there is a circular reference. I've created a relationship in the qry DES window between the two [AssyID] fields.
I even tried circumventing it and using a DLOOKUP, but I can't get it to work: here's what i have in the control source for that field:
=DLookUp("MinPerAssy","qry_MetalsItems_MinPerAssy","AssyID='" & [Forms]![qry_MetalsItemsActive subform]![txtAssyID] & "'")
I've been working on this for DAYS! please tell me what's wrong.
I have a form that tracks Jobs and a subform that tracks various items for each Job and the status for each: Completed, elapsed minutes, etc. Each item might require additional Processes and I want to know how long it took for each item as they are completed. So, essentially, I want a subtotal for each item, which includes how long each of of the processes took.
The subform is fed by a query called "qry_MetalsItemsActive" with a field for the time it takes to complete a process. Each process has a unique ID. When a process is part of a larger assembly, we have a field called ParentID, which will be equal to whatever the ID was of the parent.
An example:
Record1, ID=1, ParentID=Null
Record2, ID=2, ParentID=1
Record2, ID=3, ParentID=1
unfortunately, the creator of this table only populated the ID in the ParentID field if it was not the Parent, so some are blank and some are not. I've used this to identify blanks as Parent records and non-blanks as child records.
So, I created a new field in the main query called AssyID: IIf(IsNull([ParentID]),[ID],[ParentID])
So, in my example
Record1, ID=1, ParentID=Null, AssyID=1, minutes=20
Record2, ID=2, ParentID=1, AssyID=1, minutes=30
Record2, ID=3, ParentID=1, AssyID=1, minutes=10
Now, I can sort by this field in the subform datasheet view and see each record and identify the ones that are part of the same assembly, without grouping them together. BUT, I still only see how long each record took, NOT a subtotal of 60 minutes.
I want another field that tells me the subtotal for the assembly: 60 minutes
Then, I created another query called "qry_MetalsItems_MinPerAssy", where I group by the AssyID and then created a calculated field:
MinPerAssy: Sum([ElapsedTimeEach]/[quantity])
This works well to give me how many minutes it took for each assembly.
My problem is that I can't seem to bring this field BACK into the query that feeds my subform. I open my qry in DES view and add the new qry with the MinPerAssy field, but when I try to INNERJOIN, it tells me there is a circular reference. I've created a relationship in the qry DES window between the two [AssyID] fields.
I even tried circumventing it and using a DLOOKUP, but I can't get it to work: here's what i have in the control source for that field:
=DLookUp("MinPerAssy","qry_MetalsItems_MinPerAssy","AssyID='" & [Forms]![qry_MetalsItemsActive subform]![txtAssyID] & "'")
I've been working on this for DAYS! please tell me what's wrong.