PDA

View Full Version : Hello


jonmich
Mar 22, 2005, 02:14 AM
I have also a question about ms access.
I have to make a report and I don't know how to do it.
I can make a report but now I have to make a kind of dynamic report.
I have to make a report about vehicles which have to do several tests. So there are cars which do 3 tests but also cars which do 2 or 4 tests.
Now my question is:

Can I make one report where the amount of tests will be adjusted automatically when the report has to be generated?

ScottGem
Mar 22, 2005, 07:28 AM
In a properly normalized database, what you describe is the normal way to do things.

In a properly normalized database, you would have at least 2 tables. One for the vehicles and one for the test info. The test table might look like this:

TblTests
TestID (Primary key Autonumber)
VehicleID (foreign key)
TestType
TestResults

To produce a report you would create a query that joins the vehicle table to the tests table. You would then base a report on that query. If you group by vehicle, you can then put the vehicle info in the group header and the test info in the Detail band. Then only those tests taken by that vehicle will show up.

jonmich
Mar 23, 2005, 01:41 AM
I have 2 tables one for the vehicles and one for the tests.
Vehicles:
Vehnr(primary key)
Vehdata
Testnr(foreign key)

Tests:
Testnr(primary key)
Testdata

Is this not good for doing this? Should the reference be as in the last reply in the table tests?

ScottGem
Mar 23, 2005, 06:38 AM
You have your relationships backward. Since one vehicle can have multiple tests the FK (foreign key) should be in the Tests table. See the table structure I outlined.

You should also have a field in the test table that indicates the type of test.

jonmich
Mar 23, 2005, 06:54 AM
But one test can belong to multiple vehicles also.
Do I have to make another table where just those 2 fields are in?
Should this help and then link each field of this table with the primary key of the 2 other tables:

Test_VEH
VEh_no
Test_no

Like this and then link this table to vehicles and tests
For the type of tests, isn't the name not enough?
What else do you mean with the type?

ScottGem
Mar 23, 2005, 04:53 PM
I was just dealing with the test RESULTS. I figured that a test would apply to several vehicles and assumed you also had a tests table that described the tests themselves.

To explain this further you have a many to many relationship. One vehicle can have multiple tests, and one test can be given to multiple vehicles. However, each test on a specific vehicle will only have one results sets. What we do here is use what's called a Join table. But in this case the join table does more then just join the other two since it records the results.

So you have three tables: Vehicles, Tests, Test Results. The Vehicles table holds info about the vehicle (i.e make, model, year, etc.). The Tests table holds info about each test (i.e. Testname, equipment used, etc.). The Test Results table holds info about what vehicle, what test and what the results were. The only differences in my original recommmendation is that TestType is a FK to the Tests table. And that the table is now tblTestResults and the PK is TestResultsID.

jonmich
Mar 24, 2005, 12:16 AM
I know but I can't generate a report at runtime?
It always has to be created according to a query or isn't it?
I think I always have to make a query for each vehicle with its tests?
Am I wrong?

ScottGem
Mar 24, 2005, 06:29 AM
I very rarely base a report on a table. Almost all my reports are based on queries. This is because, in a properly normalized database, you have to create a query to join multiple tables to get all the data you want. That's the most efficient way.

You need to join all three of the tables we discussed for this report. Then follow what I said originally by grouping on Vehicle. And you will have your report.