Show additional field in subform when user makes the right selecti

P

Pete

I have a master/detail form/subform based on tables for Purchase Orders
(master) and their order lines (detail).

I have a table for 'Categories' (around 30) which can be selected for each
PO line (detail).

I am displaying an additional field in the detail section so that users can
assign a vehicle to that PO line when the user selects either 'Vehicle -
Purchase', 'Vehicle - Maint. Repair' or 'Vehicle - Project Repair' from the
'Categories' drop-down for each PO line. I have a master table with vehicle
details.

I could just add an additional field to the detail table (PO order lines),
but that would mean all records with a category other than those above would
have a field for a vehicle ID which would not be relevant, and would be
inefficient.

I presume I need an additional table (for efficiency) to facilitate this but
I am unsure how to incorporate this.

I would think the additional table would hold the PO #, Vehicle reg &
Category ID for either 'Vehicle - Purchase', 'Vehicle - Maint. Repair' or
'Vehicle - Project Repair'.

Any comments would be greatly appreciated.
Many thanks in advance.
 
A

Allen Browne

If there's only one or two of these related fields that are
category-dependent, it probably makes sense to just provide them in the
related table. Make them as generic as possible, e.g. you might call the
field Identifier rather than VehicleID, as things in other categories may
have some kind of identifier also.

If there really are several different kinds of fields that are
category-dependent, you might have to create related tables to hold this
additional data. Search on the keyword subclass - that should give you leads
on this idea. (In general, I try to avoid doing this if I can get away with
it, as you really want to keep your structure as simple as possible.)

It is posible to use the Current event of the main form to show/hide a
control in the subform depending on the category. However, toggling the
Visible property will affect all rows in the subform (in
continuous/datasheet view.)
 
P

Pete

Allen Browne said:
If there's only one or two of these related fields that are
category-dependent, it probably makes sense to just provide them in the
related table. Make them as generic as possible, e.g. you might call the
field Identifier rather than VehicleID, as things in other categories may
have some kind of identifier also.

If there really are several different kinds of fields that are
category-dependent, you might have to create related tables to hold this
additional data. Search on the keyword subclass - that should give you leads
on this idea. (In general, I try to avoid doing this if I can get away with
it, as you really want to keep your structure as simple as possible.)

It is posible to use the Current event of the main form to show/hide a
control in the subform depending on the category. However, toggling the
Visible property will affect all rows in the subform (in
continuous/datasheet view.)

Many thanks Allen.

Adding the VehicleID field to the subform table (detail) is certainly the
easiest/convenient option and so I will follow this through.
I did wonder if I could append the PO #, Vehicle ID & CategoryID to an
additional (junction) table and have lookups for the additional fields on the
subform - based on the PO #.

Would this be a possible alternative?
Many thanks.
 
P

Pete

Allen Browne said:
Yes, that's possible.
That's subclassing.

I can't find any info on "subclass" withing access. Would you kindly point
me in the direction of a relevant article?

Many thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top