This is probably a stupid question, but how do I access the recordsource of
Open the report in design mode. Click View -> Properties on the menu.
How can I do joins in a report? I know how to do it on a query, but
then Access won't see the hierarchy and won't present the report in a
hierarchical way.
You don't do joins in a report - only in a query.
Could I create a table joining Part and PartsInPart and use the hierarchies
and sorting window of the report to link all levels? Well, it's worth a try
anyway.
You probably won't want to do that. There is a 1-M relationship
between Part and PartsInPart. This is sufficient. Don't worry about
how complicated the recursive relationship looks.
Thanks Kris, my SQL might be occasionally rusty, but my VBA knowledge is
inexistent (the main application, ie not the one for the reports, presents
the parts in a treeview c# control).
You can use Dlookup() without having to delve into VBA.
Tell me if I understand this correctly. Do you currently have a report
that looks like this:
Order header information:
Product 1.
First Part in Product 1
Sub part of first part
Another sub part of the first part
A sub-sub part of the first part
Second part in product 1
Product 2.
. . .
For instance:
If Part contains:
PartID PartName
1 Car
2 Door
3 Handle
4 Glovebox
5 Truck
6 Screw
7 Glass
8 Seat
9 Cushion
And PartsInPart contains:
MasterPartID ChildPartID
1 2
1 8
2 3
2 7
3 6
1 4
5 4
5 2
5 8
8 9
If an order is placed for a product that contains a car, then your
report (currently) looks like:
Order header information:
Some product
1
2
3
6
7
4
8
9
. . .
And you want it to look like:
Order header information:
Some product
1 (Car)
2 (Door)
3 (Handle)
6 (Screw)
7 (Glass)
4 (Glovebox)
8 (Seat)
9 (Cushion)
. . .
Is the first example what you currently have and the second example
what you really want? If that is the case, add a text box to the right
of the part# and use the DLookup() funciton: =Dlookup("PartName",
"Part", "PartID = " & NameOfControlThatHasPartID )
If I have misunderstood, then perhaps we should look at that SQL
statement.
-Kris