How to populate fields depending on another field in a form

tmd63

Hobbyist relational database creator
Local time
Today, 13:44
Joined
Oct 26, 2016
Messages
20
I have a number of tables and a table listing the linked tables. These are a series of parts tables with data for each type, but I need to list and update/add depending on the type of part (so I may have a type capacitor or type resistor, with fields of value, voltage for capacitors, but value, power for resistors and I need to either add or update the values after selecting the type. How can I do this without using a sub field form?
 
You generally would have supplementary tables to "feed" combo boxes to enable you to select from a prescribed range of values.
You need to include forms to maintain the values you want to allow.

Access offers a mutli-value field (MVF) which does the same thing in a seemingly more accessible way, but this actually does the same process behind the scenes, but using the access would prevent you moving away from access in the future.

If you don't have supporting tables, you would have to allow free text entry, and that is likely to result in errors.

Even simple things like a size will result in typos, and rather than showing, say 10mm where appropriate, you are likely to get 10mm, 10 mm, 10mmm, and just 10, if you don't control the input.
 
I have a number of tables and a table listing the linked tables.
These are a series of parts tables with data for each type, but I need to list and update/add depending on the type of part (so I may have a type capacitor or type resistor, with fields of value, voltage for capacitors, but value, power for resistors and I need to either add or update the values after selecting the type. How can I do this without using a sub field form?
A table listing other tables is a non-typical design choice. Maybe you can provide sample data to help us get the big picture here.

A screen shot of the relationships diagram would be good too.

Thank you.
 
These are a series of parts tables with data for each type,
Therein lies a problem.

Do you think that Boeing has a parts table for every different type of part in an airplane? I can assure you they do not. They have/had too many parts tables but only because new applications refused to use the parts masters created by other applications.

You should have only ONE Parts table. There are ways to deal with multiple types of attributes if you are interested in fixing this problem.

Regardless, If you have many small lookup lists to manage, it becomes problematic to make a new table for each and if you embed the value list, the user can't easily change it. Here is a link to a mini-app that I include in almost all of my applications.

 
Capture.PNG

To give an idea these are tables that have a link by Part Number 'ONLY'.
So the relationship is a table which lists the part under strField1 and I can add the strTblName to each part via a separate table (if needed)
But depending on which table, there can be upto 28 strFields (strField1 to strField28). More could be added later.
I want a simple form that displays the correct field per part and allows new parts to be added by selecting the correct master table.
Normally each table is opened and the part fields visually inspected, But you have to find each part field on a word document and use multiple screens to cross check. I am trying to make a single form that will look like the original to make checking and entry easier.
Note: the public table formats can not be altered! Only data in those fields can be changed/added/checked.
 
Last edited:
Therein lies a problem.

Do you think that Boeing has a parts table for every different type of part in an airplane? I can assure you they do not. They have/had too many parts tables but only because new applications refused to use the parts masters created by other applications.

You should have only ONE Parts table. There are ways to deal with multiple types of attributes if you are interested in fixing this problem.

Regardless, If you have many small lookup lists to manage, it becomes problematic to make a new table for each and if you embed the value list, the user can't easily change it. Here is a link to a mini-app that I include in almost all of my applications.

If I could re-make the tables. I would have them in a single ODBC part database and use separation queries into the CAD libraries, but I have to work the other way round in this case (unfortunately).
 
In your own application, you can define the tables however best suits the application. There is no reason to allow external forces to cause you to make poor schema design choices.
But depending on which table, there can be upto 28 strFields (strField1 to strField28). More could be added later.
If you are not going to normalize the schema, you can't normalize the forms. Each table needs a separate maintenance form since the validation rules, assuming you bother with validation, will be different.

Use the value in strTableName to choose which form to open.
 
That is what I am trying to do, Using one form with 28 fields, the population of which is dependent on the name of the table that populates it. maybe using a subform.
 
I devote a lot of time to helping people learn how to use Access. Sometimes I have helpful examples I can post to illustrate concepts. Sometimes I can write snippets of code. But, when you're intent on creating a non-normalized solution which I would never do, I can only offer high level advice but nothing concrete.

A different way to approach this instead of using x columns that are filled with variable types of data depending on what type of part is showing, is to use an Entity-Attribute-Value model. That way, you have a "header" table with all the common fields. Then you have a child table which has a separate row for each of the variable attributes. You need a table that defines the attributes for each part type. I have an app I created using this model for an insurance company. Each type of policy has around 30 common attributes. Name, address, etc. And some number of variable attributes. When the user wants to define a new type of policy, he adds any new, previously undefined attributes to the fields table and then he picks all the variable fields for THIS policy type (think part type here). When the user is entering data for a new policy for a new customer, he chooses the policy type. When the header record is saved, the code runs an append query that selects all the fields for this policy type and appends a record for each to the child table that will hold the specific values for each policy. The point of the application is to ensure that all policy documents are consistent in the data values. Therefore, if the policy limit changes, you change the limit and reprint all the documents. Without this app, the user had to remember which documents had which fields and so which documents needed to be changed if any value in the agreement changed.

This an ultimately infinitely expandable solution. It doesn't matter how many policy types you end up having to define. It doesn't matter how many variable fields you end up with in total and it doesn't matter how many of these fields are required for each policy.

You can stick with your limited solution (which I don't recommend because it will require code maintenance whenever you add a new type of part which my Entity-Attribute-Value solution does not) if you are very sure you know the boundaries of your part type universe up front and you are positive you will never need more than 28 columns to handle all the variable values.

You can create a single form with 28 controls. The controls are bound to fld1, fld2, etc. When you go to a new record, you need to read the labels table and loop through the fields so you can set the caption property of the controls to fld1, fld2, etc. This makes the form look different but it will be a bitch to maintain. You won't be able to easily reorder the columns, when you add new ones, the always go at the end.

The other thing I did with my EAV model is create lookup tables to help me validate certain types of data.

Here is a picture of the data entry form. The fields in the header are fixed but the ones in the list are the variables. Notice that the yellow field has a dropdown for a combo. Because this field is several different stacked controls, when the field needs a combo, the appropriate one can be displayed for the particular field. As you click into each field, you will see a different value list. This is handled by having a column in the table that defines each attribute with a field to hold a query name for the RowSource. So, the code just sets the RowSource to whatever value is in the field.

DGT_DataEntry.JPG
 
Non sequitur; had OP waited one week to post, he would have responded exactly 500 days later.
 
If it was up to me. I would have created this with nomalised tables and used queries to pull the information together for the Altium Libraries but some backward non-programming idiot made this and now I have to sort their sh17.
 

Users who are viewing this thread

Back
Top Bottom