Need to have SQL INSERT INTO statement

sburgess

Registered User.
Local time
Today, 07:30
Joined
Mar 16, 2006
Messages
13
I have an Employee database, that tracks Employee information and training. I have a form set up, that captures all the Employee Information, with the Employee No being the primary key. In this form, I have a subform, that lists all the training for that Employee (rows of training can be added). This subform information is housed in a MasterMatrix, which includes the Employee No (parent/child link), and the training class, and status of the training.

What I need to do is, create a button in the form that when a new employee is added to the database, it will take the Employee No from the record, and add that and 4 training classes (which are standard classes for new employees), and add them to the MatrixMaster.

Any help would be great.

1st table - tblEmployee (need EmpNo from here) - This is also main form
2nd table - tblTrainingClass (need Training Class, Status, WHERE NewEmployeeTraining = yes)

3rd table - tblTrainingMatrixMaster (where info is going to - this is also a subform, with parent/child link to EmpNo): - EmpNo, Training Class, Training Status
 
Also, I received a suggestion that I don't need to pull from 2 tables, since I have the link in my form/subform. Here is the code that I have so far:
Code:
 Dim strSQL As String
    
    strSQL = "INSERT INTO tblTrainingMatrixMaster(EmpNo, TrainingClass, TrainingStatus)"
    strSQL = strSQL & "SELECT" & Me.EmpNo & "AS EmpNo, TrainingClass, Status"
    strSQL = strSQL & "FROM tblTrainingClass WHERE NewEmployeeTraining = 'yes';"
    
    CurrentDb.Execute strSQL

I'm curious to know if I need to call out the current database first, before I can use the Execute command.
 

Users who are viewing this thread

Back
Top Bottom