OK, Let me explain the way I was thinking about this with an example. The
database that I set up was also for a limited number of analyses that are
carried out in a small lab on a plant. There are several types of sample
that are taken and recorded on this database, such as:
- final product lots
- intermediate product lots
- process effluent
- environmental scrubbers
Each different type of sample is listed in a SampleType table.
There are several different analyses that are performed, such as:
- water content
- chloride content
- product purity
Each of these is stored in a Components table (this is what I called Tests
in the original message, but components is a better name as you can measure
several components in one analysis/ test - you could also have a TestMethods
table).
Each sample type can be tested for one or more components, and each
component can appear in one or more sample types - ie there is a many to
many relationship between sample types and components. This requires a third
table that is related to the SampleType table by the SampleTypeID, and to
the Component table by ComponentID. This table represents either the testing
schedule for each sample type, or the components that could be tested in
each sample type, or both. So, the product purity will be a test for the
final product, and chloride will be a test for a scrubber.
Its uses are:
- in my database, to create the records in the temporary table that is used
for data entry - this means that the user sees a list of the correct
components for the sample type being tested, and merely has to fill in the
results - there is no need to select the components first.
- it could be used to limit the components that the user can choose from to
just those that make sense for the product being tested (this would involve
using a query based on this table as the source for a combo box).
- you can add extra fields to this table showing the maximum and minimum
permissable values, and use these to validate the results entered.
- you can add a field to this table to control the order in which the
results records are displayed.
- you could add a yes/ no field to this table to indicate if a specific
result was compulsory or optional.
So, in my database the following process is used when a user enters a new
sample:
- The user selects a sample type from a drop down list.
- VBA code creates a record in the Samples table for the appropriate sample
type, and creates a temporary table containing one record for each test in
the SampleTypeComponents (testing schedule table). (I could have also
created these records directly in the SampleResults table, but I chose not
to. It would probably have made sense to create the Sample record in a
temporary table as well.)
- A results form is opened showing the sample record on the main form, and
the temporary table records on a subform.
- The user clicks a command button when all the results are entered, and
this runs an append query to add the temporary table to the SampleResults
table.
- There is also a "cancel" button on the form and this deletes the sample
record and closes the form.
A simpler, but less user friendly method, would be to just have the results
entry form as a main form/ subform arrangement with the subform based on the
SampleResults table. You could put a combo box on the subform that lists the
component name (but is bound to the component ID), and limit the list of
components presented to the ones specified for the sample type under test in
the testing schedule. If you don't have the testing schedule as part of the
database then the user will be presented with every component in your
components table - including ones that don't make sense for the sample they
are testing. The user will also need to know or have to look up the testing
schedule for the sample.
The fact that you only have a small number of types of analysis is not
really important to how you design the database. It's still nearly certain
that you will change the tests that you do over time, and your database
needs to be able to cope with this. If you were doing a large volume of
analyses on a huge number of sample types, then the basic database design
would still be the same as for a small number of samples, although you would
probably buy a proprietry LIMS in that case.