Z
Zulfi
Hi All,
I have 2 tables Employees [EmployeeID, EmployeeName] and LeaveRecord
[EmployeeID, LeaveStart, LeaveFinish,LastLeaveFinish]
I try to insert data into leave record from a form with the following SQL:
Private Sub Command3_Click()
Dim StrSQL As String
StrSQL = "INSERT INTO Leaves ( EmployeeID, LeaveStart, LeaveFinish ) " _
& "SELECT " & Me![Combo7] & ", #" _
& Me![Text11] & "#, #" _
& Me![Text13] & "#;"
StrSQL = "UPDATE Leaves set LastLeaveFinish=LeaveFinish where EmployeeID=" &
Me.EmployeeID
DoCmd.RunSQL StrSQL
End Sub
However, if I input new record for EmployeeID already exist in LeaveRecord
table it return error (run time error 2501).
Appreciate your help.
Zulfi
I have 2 tables Employees [EmployeeID, EmployeeName] and LeaveRecord
[EmployeeID, LeaveStart, LeaveFinish,LastLeaveFinish]
I try to insert data into leave record from a form with the following SQL:
Private Sub Command3_Click()
Dim StrSQL As String
StrSQL = "INSERT INTO Leaves ( EmployeeID, LeaveStart, LeaveFinish ) " _
& "SELECT " & Me![Combo7] & ", #" _
& Me![Text11] & "#, #" _
& Me![Text13] & "#;"
StrSQL = "UPDATE Leaves set LastLeaveFinish=LeaveFinish where EmployeeID=" &
Me.EmployeeID
DoCmd.RunSQL StrSQL
End Sub
However, if I input new record for EmployeeID already exist in LeaveRecord
table it return error (run time error 2501).
Appreciate your help.
Zulfi