473,549 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to add multiple records to a table via a form?

27 New Member
I am a beginner in Access as of last week, so pardon my inability to understand Access; currently I am on Access 2013. I am trying to add multiple records to a table. For example, I have multiple employees going to a training so instead of inputting them one by one, is there a way to input into all the employees that did go? I attempted in a form to make a list box, use multi select to select the employees that attended, and then add but it did not seem to work. So I have one table that is Employee and their ID # and another table that indicates which trainings employees have gone to/training name, the costs, the date, and receipt attachment. Later I am planning to make a query to get how many trainings each has attended and the sum of the amount spent on each Employee.
Feb 5 '19 #1
22 5741
twinnyfo
3,653 Recognized Expert Moderator Specialist
beginneraccess

Welcome to Bytes!

You should also have an EmployeeTrainin g Table, which has the Training Course and the Employees who attended that training.

There many ways to add these employees to this table. It just depends on how elaborate you want to make it.

One way is to have a Form. On that form, you select the training course. Once you select the course, there would be a subform on that main form that lists all the attendees for that course, as well as a combo box that holds all the employees who have not attended that course. Select an employee from that combo box, click a command button to add the person to the course. Behind the button is VBA to add the person to the course and requery both the subform and the Combo Box. You could also use a List box as you have described to allow selecting multiple employees at once.

This is an outline of one way to do it, but not the answer itself. We can't do that for you. However, we are glad to work through details one step at a time and troubleshoot any sepcific problems you come across.

Hope this hepps!
Feb 5 '19 #2
beginneraccess
27 New Member
Dear twinnyfo,

thank you for your quick response. So far I have created a form and a subform which made it possible to select multiple employees and add to the subform. However, despite selecting multiple employees it seems to only add to one employee. May I ask if this is the first form error or the subform error?

Attached Images
File Type: png screenshoot.PNG (16.1 KB, 2670 views)
Feb 5 '19 #3
twinnyfo
3,653 Recognized Expert Moderator Specialist
What is the VBA you are using to copy the records to the second table. That is our starting place.
Feb 5 '19 #4
beginneraccess
27 New Member
Sorry I did not do a VBA, so have been trying to make one right now...
I am not good with coding and did not know anything about VBA until you mentioned it, but this is what I got...
Option Compare Database
Option Explicit

Expand|Select|Wrap|Line Numbers
  1. Private Sub lstAll_AfterUpdate()
  2. Dim SQL As String
  3.     SQL = "SELECT tbStaff.[Employee ID], tbStaff.[First Name] & " " & tbStaff.[Last Name] AS EmployeeName FROM tbStaff ORDER BY tbStaff.[First Name]" & "FROM [tbStaff] INNER JOIN [tbStaff]" & "ON [trial for both].[Field Int ID]=[tbStaff].[Employee ID];"
  4.  
  5.     Me.delete1.Form.RecordSource = SQL
  6.     Me.delete1.Form.Requery
  7.  
  8. End Sub
I'm guessing SQL = "SELECT tbStaff.[Employee ID], tbStaff.[First Name], tbStaff.[Last Name]" should be the beginning

Without the VBA, if I don't do multiselect on the list box it will let me update them one by one. But it seems like too much if more than 20 employees go to a training, plus trainings can also be a lot
Feb 5 '19 #5
twinnyfo
3,653 Recognized Expert Moderator Specialist
I’ll have to take a look at that tomorrow. Or, someone else may chime in....
Feb 5 '19 #6
beginneraccess
27 New Member
Thank you! I will also be trying to learn how to code slowly. Hopefully while learning I may be able to see what is wrong.
Feb 5 '19 #7
twinnyfo
3,653 Recognized Expert Moderator Specialist
We can go as slowly or as quickly as you are able to grasp. I can be very patient with those who eagerly seek to learn.
Feb 5 '19 #8
beginneraccess
27 New Member
Thank you for being very helpful!
Feb 5 '19 #9
PhilOfWalton
1,430 Recognized Expert Top Contributor
I think you have made a good start,and Twinny's posts certainly will put you on the right track, but setting up tables correctly and having meaningful field names is a great help.

You need 3 tables, 1 for Employees holding information solely about that person. Absolutely nothing to do with courses.

Expand|Select|Wrap|Line Numbers
  1. TblEmployees
  2.     EmployeeID            AutoNumber    Primary Key
  3.     EmpLastName                 Text
  4.     EmpFirstName                Text
  5.     EmpAddress1                 Text
  6.     EmpAddress2                 Text
  7.     EmpAddress3                 Text
  8.     EmpTown                     Text
  9.     EmpCounty                   Text
  10.     EmpPostCode                 Text
  11.     EmpEmail                    Text
  12.     EmpPhone                    Text
  13.     etc.
  14.  
Note 2 points
1) There are no spaces in the field names (so you don't need to
use square brackets [] round the names
2) There should only be 1 word in each field. It is comparatively easy to combine fields together (EmpFirstName & EmpLastName to give EmpName. Splitting John Edward Smith into first & last names is much trickier.

Table of courses
Expand|Select|Wrap|Line Numbers
  1. TblCourses
  2.     CourseID        AutoNumber    Primary Key
  3.     CourseName            Text
  4.     CourseCost            Currency
  5.     CourseStartDate       Date
  6.     etc
So now you have 2 independent tables. The Employees stand on their own, and could also be used for say grades achieved, and the Course table is there, regardless of whether or not there are any students attending.

Now the important table which puts the student on the course
Expand|Select|Wrap|Line Numbers
  1. TblJoinEmployeeCourse
  2.     CourseID       Long Number   Joint Primary Key
  3.     EmployeeID     Long Number   Joint Primary Key
  4.     CourseDate     Date
  5.     Fee            Currency
  6.     DatePaid       Date
  7.     Grade          Number?
  8.     Comments       Text
  9.     etc.
Set up relationships between the 3 tables and enforce referential integrity.

Now to your form.

On the header, you need a combo box to select on which course you are entering the Employees together with the course date.
The single select list box or Combo Box showing the Employees is fine (except I suspect nobody will know the EmployeeID Number, so just use the names sorted alphabetically.

There should be a continuous subform showing the employees selected. As each employee is selected from the list box, we add this to the subform, and remove that person from the list box. Equally, if you have a wrong employee on your subform, you delete it and add the person back to your list box.

This is only a (brief) outline. When you get stuck or have any questions, I'm sure Twinny or I will help you on your way.

As an aside, I am extremely ancient, and have difficulty in reading the small print on your form. For the sake of the ancient ones, can you use 12 point fonts. The only justification I can see for small fonts is where there are a hell of a lot of controls on your form, and space is tight.

Phil
Feb 6 '19 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2676
by: mellie | last post by:
Hi there, SQL 2000 database with ASP I've found many things "out there" regarding updating and deleting multiple records with checkboxes but I can't seem to find anything about adding them. A user wants to create a price list for their client and they need to add parts to it in a separate table. I would like to display the list of...
1
4740
by: andree | last post by:
Hello, I have a form where a user may paste multiple records. The form has an AfterInsert procedure. The procedure copies the newly inserted record into a different table for audit purposes. When one record is pasted, all is working fine. If multiple records are pasted, the AfterInsert event gets fired before the Paste Confirmation...
12
2982
by: shank | last post by:
I'm trying to use online samples for submitting multiple records from ASP into a stored procedure. Failing! Through the below form, a user could be submitting many records at a time. I'm not getting any records inserted. For troubleshooting, I cut the form down to 1 textbox and when submitted it populated 5 rows of the same data. So I know I'm...
1
1452
by: marylipscomb | last post by:
I have a form that has a place to enter Adjacent Properties, which I only have room for like 6 right now to be entered.. Sometimes their could be 100 entries. Where you enter that info on the from, kinda looks like a table I have AdjacentOwnerName SurfaceAdjacentInterest Mineral AdjacentInterest so on.....
4
9792
4Him
by: 4Him | last post by:
First off, let me say this is a great site! I've just started working with Access and much of my success is from what I've read here! Background: I have a form, driven off a single table. Goal: To have multiple fields copied and pasted into multiple records with a single button click. Work Done: In the form I have multiple fields, but for...
8
4765
by: jmarcrum | last post by:
Hello all, i have a continuous form that displays about 1000 records and opens when I click a button. When the form opens, the user has the option of checking a checkbox that is located beside each record. The checkbox is labeled "Move" (for moving multiple records at a time to another year). Of course, the checkbox is set as a control...
2
2357
by: phill86 | last post by:
Hi, i have a recordset that updates a table which works fine when you add, update and paste a single record but if you try and paste multiple records it will only update the table with the prevoius records and it will ignore the new pasted records i am running the following code on the afterupdate event in the form Please Help ...
4
5275
by: phill86 | last post by:
Hi, i have a form that runs a query in a recordset on the after update method if i copy and paste one record at a time the query picks up the records in the underlying table but if i paste multiple records the query fails to pick up the set of pasted records i think the after update method is running before the table is properly updated when i...
6
12822
by: mcupito | last post by:
I'd like to list the multiple records on the form. I'll attach images because it's just easier that way. On the form, instead of the row selector, I'd like it to just list the different Totals. I understand I organized them as Tabular in the design view, is that preventing this change? Thanks.. ...
5
1640
by: farooqkhan123 | last post by:
Hi I have a table with several fields, the following are relevant for example. Serial - Name - Quote Number - Policy Number - Date - Rate Only Serial is a Primary Key and Unique. Name of this table is "CONSOLIDATED". I also have a form that opens up specific records showing various fields from this table. Form name is "PUN Prefill". ...
0
7524
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7960
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6048
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5089
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
766
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.