Asked by:
Allow a Form to Add Multiple Records at a Time

Question
-
Hello,
I'm creating a database from scratch, was nearing completion, and have run into 2 issues that the users have requested. The scenario is that I have a database with 5 tables that need to be edited for each new sample result from lab equipment, the tables being
- The status of the lab (such as barometric pressure.)
- Status of the instrument (which instrument was being used) which references the 1st table.
- The type of sample being analyzed.
- A many-to-many table joining tables 2 and 3 so that each instrument and sample are recorded as well as data pertaining to that current sample test (such as time test was performed), with this form referencing tables 2 and 3.
- A sample will be run on a single instrument usually 2 times to make sure that a single test didn't happen to give a wrong value due to make sure the test results are repeatable, but sometimes it is done 1 to 4 times due to different circumstances, so there is a result table which references table 4. This is done so that I don't have table 4 with 4 columns to enter data in, with most of the time the last 2 columns having no data in them which I was taught violates normal form for databases.
Given this, here are my problems. First, I have setup a form to allow lab personnel to enter data into Microsoft Access through one form instead of 5 different forms, on for each table. This is done by having a form for the 5th table have a subform for table 4, which has subforms for tables 2 and 3, and then table 2 having a subform for table 1, with combo boxes allowing a user to choose data from previous records for all the subforms. So I have a form that is 4 levels deep due to subforms. The problem is that to enter NEW data, a user currently has to:
- Open the form for table 5 that has the subreports,
- right-click on the combo box that changes the data for the subform that is for table 4,
- select "Edit List", then has to edit list again for the other combo boxes for the forms for tables 2 and 3,
- for the form for table 2 need to repeat steps to reach the form for table 1,
- select New Record,
- enter the new data,
- click save,
- then back in the subform for table 4 has to click refresh all, (Note: If an instrument has already been used to analyze a sample once during a day then the user will only have to select the value from the combo box for instrument status for that day so steps 3 - 7 can be skipped which does save some time for entering new data.)
- then click new record,
- enter the new data,
- save,
- go back up to the main form,
- refresh again,
- select from the combo box the primary key value for the new value entered for the form for table 4,
- FINALLY enter the first result from the test,
- and then for tests done on the same sample, just like how Steps 3-7 can be skipped, steps 2-14 can be skipped when if more than one test is being done on the same sample by copying the record into a New Record for the form for table 5.
I've talked with the users and we agree that this is ridiculous to have to be done every time a new sample arrives in the lab that needs to be analyzed. So the first question is, is there anyway to setup a form so that a user can just select everything without going through multiple forms, refreshing, etc. and have as few steps as possible, preferable (not needing to be this short, but anything shorter is better) something like this:
- Open the form for table 5,
- create a new record,
- allow values to be entered for the lab condition for table 1, instrument status for table 2, type of sample for table 3, conditions of instrument when analyzed for table 4, and then the actual results for table 5,
- and then copy that record for each time the sample needs to be re-tested and change the result so each result is recorded.
Again, if more steps than that are needed, that's fine, but having to do 16 steps for each new sample at the beginning of each day (10 steps if the instrument has been run the same day) is ridiculous, so anything shorter than that would be great.
The second things that the users have requested, and this is 2nd in priority to the 1st problem mentioned above) is to instead of having to copy the final form each time the sample is rerun on an instrument is to have another box to enter data appear in each time a result box is filled in. For example, when you go to an self-checkout at a store you don't need to get a new transaction for each item. You scan an item, keep scanning items until you have nothing left in your cart, and then select checkout. Likewise, the users want once one result has been entered for another box to appear (which I know how to do with events for labels and text boxes so they will only show if there is data in another box) and then to be able to enter values into the boxes until all test result have been entered. This way all the results for a sample being tested can be entered and reviewed on the form at the same time so there will be no chance of entering the same result twice or forgetting to input one.
Again, the users really need the steps being cut down from 16 steps for new samples, that is the top priority, while being able to enter multiple sample results at a time so New Record doesn't need to be selected for each retest is the bottom priority.
-Tommy
Friday, January 3, 2020 11:35 PM
All replies
-
Hard to answer without spending time with the real database design, but IIUC perhaps it would make sense to have a form with some "temporary" tables for data entry, and a final Save button where the data is dispersed to the various tables.
-Tom. Microsoft Access MVP
Saturday, January 4, 2020 1:12 AM -
Again, the users really need the steps being cut down from 16 steps for new samples, that is the top priority, while being able to enter multiple sample results at a time so New Record doesn't need to be selected for each retest is the bottom priority.
Hi Tommy,
In those (more complicated) cases I use an unbound form for data entry. After pressing the Save button, the data is distributed over the appropriate tables.
As this is special to your case, you need to write the code to do the proper distribution. But yes, it can be done.
Imb.
Saturday, January 4, 2020 7:25 AM -
How would your unbound form deal with this requirement: "sometimes it is done 1 to 4 times"?
Four sets of controls, presumably? Five if that ever becomes necessary? I don't think that's good design.
-Tom. Microsoft Access MVP
Saturday, January 4, 2020 11:44 PM -
How would your unbound form deal with this requirement: "sometimes it is done 1 to 4 times"?
Four sets of controls, presumably? Five if that ever becomes necessary? I don't think that's good design.
Hi Tom,
There are many different ways to to handle more complex cases. It all depends on the complexity, and what you want.
As with adding the rough data first to a table, you can choose for adding it row by row (per record), or add 4 rows (records) and modify the different records.
My preference for (unbound) forms is that you have far more control over the entered data in terms of checks in the BeforeUpdate events, and far more actions in the AfterUpdate events. Moreover, you can add command buttons to take over many repetitive tasks.
I can give you 2 examples (of the many I have).
The first is for adding fields to a table. The right 6 columns are just identical subforms. (The most left is also identical, but tuned in a different way.)
After pressing "Opslaan" (all checks are already done) meta data tables are filled with the appropriate data, fields with the correct types are added to the tables, and the changes in data-definition are stored in a table for automatic update of the data-definition in the productiuon database.
The second example is for adding children to a set of parents. The complexity is that the date_of_birth is not a field in a persons record, but it is decribed as an occurence or event that "happened" on a certain place on a certain time, to which many people can be added that have played a certain role in that occurence.
Again, after pressing "Opslaan", all "valid" children are stored in the right way, including the defined parents.
Imb.
Sunday, January 5, 2020 3:17 PM -
Thank you Tom and Imb for replying over the weekend to my initial post. Here are my replies to your comments:
@Tom: You mentioned it would be hard to answer my question without the database design. Would it help if I had the table names and fields for each table with PK and FK identified, or would I have to upload the database somewhere so you could view it? Also, you mentioned making a temporary table and then using a save button. Can you elaborate on that?
@Imb: I've never tried using unbound forms before for entering information, and my textbook on Access only mentions using unbound forms for navigation. Can you refer me to a website that covers unbound forms?
-Tommy
Monday, January 6, 2020 4:16 PM -
@Imb: I've never tried using unbound forms before for entering information, and my textbook on Access only mentions using unbound forms for navigation. Can you refer me to a website that covers unbound forms?
Hi Tommy,
Alas, I have no reference. In this respect I am a self-taught user of Access. I am afraid that Textbooks only describe what standard Access offers (and that is indeed quite a lot), but not what can be done more.
With bound forms Access handles the relation between the Control on the form and the Field in the table through the definition of RecordSource and ControlSource. All works automatically then. If you have no underlying table/query, you don't need that automatic administration, and you can use unbound controls.
This kind of administration, however, is not difficult: the record is known, the field is known, the value in the control is known, and a simple update-query does the trick. VBA can all do that. Some developpers will see this as re-inventing the wheel, but I see it as extending the possibilities.
For complex problems, or creative solutions, the one RecordSource (though it can be very complex) is just not enough. Then you can switch to your own administration-system, on unbound forms, with wonderful results. Once you are in this stage, this opens again many. many new possibilities.
But back to the basic, you referred to a Textbook. Probably you are at the beginning of your Access-carreer. In that case you can better start with the standard Access approach.
Any way, much success, and enjoy your progress.
Imb.
Tuesday, January 7, 2020 10:02 AM -
I've never tried using unbound forms before for entering information, and my textbook on Access only mentions using unbound forms for navigation. Can you refer me to a website that covers unbound forms?
You'll find a couple of examples of the use of unbound forms for data entry in Families.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to amend the form design accordingly.
If you have difficulty opening the link, copy the link (NB, not the link location) and paste it into your browser's address bar.
This little demo file illustrates how to enforce the existence of at least one matching row in a referencing table, FamilyMembers, for each row in the referenced table, Families. Two examples use unbound forms. In one of these the existence of a row in the referencing table is enforced by a CHECK CONSTRAINT. That is not relevant to what you are doing, so concentrate on the other example, in which you'll find that code in the Click event procedure of the confirmation button executes two SQL statements (append queries) within a Transaction to insert rows into both tables as a single operation.
However, the fact that you are experiencing difficulties using a bound form/subforms interface does make me wonder if the problem lies in the database's physical model, i.e. the set of tables and the relationships between them. To enable us to comment on these in the first instance, the simplest thing would be for you to post an image of the database's relationships window, ensuring that it is set out clearly to show all tables, all of the columns (fields) in each table, and the relationships between them.
Ken Sheridan, Stafford, England
Tuesday, January 7, 2020 7:02 PM