Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add mutiple record to a table at once

Status
Not open for further replies.

BSC5905

Technical User
Apr 30, 2004
20
US
What I need to do is to enter 25 Technicians who has been trained on the same Test Method into the same table all at once. I have created a form named “frmTrainingRecords” based on a table called “tblTrainingRecords”to enter the data. The table “tblTrainingRecords” consists of the following fields:

EmployeeID – This is a lookup field named “cboEmployeeID” coming from tblEmployees
TestMethodID – This is a lookup field named “cboTestMethod” coming from qryTestMethods
TrainerID – This is a look up field named “cboEmployeeID” coming from tblEmployees
TrainingDate - This is a text box where I enter the date of training

What I would like to do is to select multi employees from the combo box “EmployeeID” then select the test method that each employee has been trained on from combo box “TestMethodID”, then select the trainer from combo box TrainerID and finally enter the date of training.

Once all of the data has been selected or entered, add the records to the table “tblTrainingRecords" all at once. The total number of records added to the table would be the number of technicians that I selected.
 
First, you mean Listbox. You can't do multiple selections on a combobox. Let's say you have a command button to do the addition of records. Then on the OnClick event of the button, you would have something like:
Note: in your explanation, you have two comboboxes named the same. I'm changing the trainer to cboTrainer

Private Sub Command4_Click()
Dim DB As Database
Dim RS As Recordset
Dim Employee As Variant
Set DB = CurrentDb()
Set RS = DB.OpenRecordset("tblTrainingRecords", dbOpenDynaset)
For Each Employee In Me![List0].ItemsSelected
RS.AddNew
RS![EmployeeID] = [List0].Column(0, Employee)
RS![TestMethodID] = Me![cboTestMethod]
RS![TrainerID] = Me![cboTraniner]
RS![TrainingDate] = Me![TextboxNameofDate]
RS.Update
Next
RS.Close
DB.Close
Set RS = Nothing
Set DB = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top