Private Sub addRecord_Click() Dim db As Database Dim rs As Recordset Dim rs2 As Recordset Dim i As Integer Dim X As Integer 'Connections Set db = CurrentDb Set rs = db.OpenRecordset("tblLeave") Set rs2 = db.OpenRecordset("tblLeaveDate") 'Recognizing the ID X = db.OpenRecordset("SELECT @@Identity")(0) rs.AddNew 'Checking if The Required fields was Full in If Shift = "" Then MsgBox "Employee Is Required" ElseIf txtEmployeeNr = "" Then MsgBox "Employee Is Required" ElseIf txtReasonType = "" Then MsgBox "Reason Type Is Required" Else 'Checking for 0 As sometime @@Identity can place 0 If X = 0 Then X = LastID + 1 End If rs!LID = X rs!EmployeeNr = txtEmployeeNr rs!ReasonType = txtReasonType rs!Details = txtDetails rs!RTWCompleted = cheRTW rs!StartDate = txtStartDate rs!EndDate = DateofRTW rs!AddedBy = [Forms]![frmEmployeeList]![cboUser].Column(1) rs.Update For i = 0 To txtDays rs2.AddNew rs2!LID = X rs2!CalendarDate = txtStartDate + i rs2.Update Next i ' Clean Up and Close rs.Close rs2.Close Set rs = Nothing Set rs2 = Nothing Set db = Nothing MsgBox "The Adding Process was Successful"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)