I have an employee database that I need to extract certain information from one table and place it into another table.
Table 1 has the following fields
Employee
Shift
Availability
Telephone
Job Worked (which is a combo box of job choices)
Hours Scheduled
Hours Worked and several other fields
Table 2
Employee
Shift
Job Worked
Date Worked
I want to use an add record button on the form so when selected it will copy the Employee, Shift and the Job Worked selected from the combo box to the appropriate fields on table 2. It will then add a date stamp to the date worked field on table 2.
Each day a supervisor will go into the form to populate hours which will feed into table 1. When they do this I need them to select the job worked and then have that information go into table 2 and date stamp.
I am just learning Access and VBA so made an attempt at coding the button to do this. When I select the button now it advances my form (table 1) one record which blanks out the employee and then tells me it can't accept a null value because it is a required field.
Attempted Code:
Private Sub Command223_Click()
On Error GoTo Err_Command223_Click
Dim db As Database
Dim RS As Recordset
DoCmd.GoToRecord , , acNewRec
Set db = CurrentDb
Set RS = db.OpenRecordset("TblJobWorked", dbOpenTable)
RS.AddNew
RS!Employee = Employee.Value
RS!Shift = Shift.Value
RS.Update
RS.Close
Exit_Command223_Click:
Exit Sub
Err_Command223_Click:
MsgBox Err.Description
Resume Exit_Command223_Click
I would appreciate any help that you can provide me with.
Thanks in advance
Angie
Table 1 has the following fields
Employee
Shift
Availability
Telephone
Job Worked (which is a combo box of job choices)
Hours Scheduled
Hours Worked and several other fields
Table 2
Employee
Shift
Job Worked
Date Worked
I want to use an add record button on the form so when selected it will copy the Employee, Shift and the Job Worked selected from the combo box to the appropriate fields on table 2. It will then add a date stamp to the date worked field on table 2.
Each day a supervisor will go into the form to populate hours which will feed into table 1. When they do this I need them to select the job worked and then have that information go into table 2 and date stamp.
I am just learning Access and VBA so made an attempt at coding the button to do this. When I select the button now it advances my form (table 1) one record which blanks out the employee and then tells me it can't accept a null value because it is a required field.
Attempted Code:
Private Sub Command223_Click()
On Error GoTo Err_Command223_Click
Dim db As Database
Dim RS As Recordset
DoCmd.GoToRecord , , acNewRec
Set db = CurrentDb
Set RS = db.OpenRecordset("TblJobWorked", dbOpenTable)
RS.AddNew
RS!Employee = Employee.Value
RS!Shift = Shift.Value
RS.Update
RS.Close
Exit_Command223_Click:
Exit Sub
Err_Command223_Click:
MsgBox Err.Description
Resume Exit_Command223_Click
I would appreciate any help that you can provide me with.
Thanks in advance
Angie