SonicClang
Registered User.
- Local time
- Yesterday, 19:17
- Joined
- Oct 14, 2008
- Messages
- 16
I'm designing a database for users to check material in and out of a vault. I'm to the point where I'm creating reports for them to track the materials. I have one report in mind that is just so complicated, it's tying my brain in knots.
There are three fields involved here; CSNumber, Parent1, and Parent2. When a new material is checked into the vault, it could be raw material, in which case it would have no parent material. If material is checked out, taken to a machine and processed, when it's checked back in it gets a new CSNumber, and the previous CSNumber is now Parent1.
CSNumber = bag/container number. One lot number could be split into multiple containers.
Parent1 = After material is processed it gets checked in as a new lot and new CS number. The CS number that this was made of is the parent.
Parent2 = If parent 1 wasn't enough, part of another parent can be used.
This first query is easy. "Show where CS00029 is used"
I'd like to write a query that connects the dots even further. If CS00029 is parent 1 of CS00031, then show me anywhere CS00031 is a parent for another material. So essentially, any value in either of the parent columns gets thrown into the CSNumber column... I think. Like I said, my brain is tied in knots right now.
Am I going about this the wrong way? Is this even possible? Am I making any sense?
There are three fields involved here; CSNumber, Parent1, and Parent2. When a new material is checked into the vault, it could be raw material, in which case it would have no parent material. If material is checked out, taken to a machine and processed, when it's checked back in it gets a new CSNumber, and the previous CSNumber is now Parent1.
CSNumber = bag/container number. One lot number could be split into multiple containers.
Parent1 = After material is processed it gets checked in as a new lot and new CS number. The CS number that this was made of is the parent.
Parent2 = If parent 1 wasn't enough, part of another parent can be used.
Code:
Here is an example of the values in table tblCSNumbers
CSNumber | Parent1 | Parent 2 |
--------------------------------
CS00029 | | |
CS00030 | | |
CS00031 | CS00029 | |
CS00032 | CS00029 | |
CS00033 | CS00031 | |
CS00035 | CS00031 | |
CS00036 | CS00029 | CS00030 |
CS00037 | CS00029 | CS00030 |
Code:
qryWhereUsed (User selects CS00029 from a combobox on a form and runs the query)
| CSNumber | Parent1 | Parent 2 |
| CS00029 | | |
| CS00031 | CS00029 | |
| CS00032 | CS00029 | |
| CS00036 | CS00029 | CS00030 |
| CS00037 | CS00029 | CS00030 |
Code:
This is what the results should show.
| CSNumber | Parent1 | Parent 2 |
| CS00029 | | |
| CS00031 | CS00029 | |
| CS00033 | CS00031 | |
| CS00035 | CS00031 | |
| CS00032 | CS00029 | |
| CS00036 | CS00029 | CS00030 |
| CS00037 | CS00029 | CS00030 |