السلام عليكم
ارجو المساعدة في مشكل run-time error 3021
اريد تغيير "No" ب "Yes" في الحقل Replaced الجدول tblEmployees
الكود :
Private Sub AddNew_Click()
Dim strMsg As String, strTitle As String
Dim strMsgNo As String, strTitleNo As String
Dim dbsTPIETS As DAO.Database
Dim Replace As DAO.Recordset
Dim dbMat As DAO.Database
Dim rstMat As DAO.Recordset
Dim strSQL As String
strMsg = "Do you want to add a new recrut....?"
strTitle = " Add OK"
If IsNull(Me.Employee_ID) Or Me.Combo1 = "" Then
MsgBox "Pease Enter the Employee_ID or Replacement", vbOKOnly, "Required Data"
DoCmd.Close acForm, "frmAddEmp"
Else
Set dbsTPIETS = CurrentDb
Set Replace = dbsTPIETS.OpenRecordset("tblReplacement", dbOpenDynaset, dbInconsistent)
Set dbMat = CurrentDb()
strSQL = "SELECT tblEmployees.Employee_ID, tblEmployees.Replaced FROM tblEmployees WHERE (((tblEmployees.Replaced)= " & "No" & ")) and ((tblEmployees.Employee_ID)= " & TextMat & " );"
Set rstMat = dbMat.OpenRecordset(strSQL, dbOpenDynaset)
With rstMat
.Edit
!Replaced = "Yes"
.Update
End With
Me.Refresh
Replace.AddNew
Replace!Employee_ID = Me!Employee_ID
Replace!strFullName = Me!strFullName
Replace!strAdministration_ID = Me!strAdministration_ID
Replace!strDepartment_ID = Me!strDepartment_ID
Replace!INTITULE = Me!INTITULE
Replace.Update
Replace.Close
End If
If MsgBox(strMsg, vbQuestion + vbYesNo + vbDefaultButton2, strTitle) = vbYes Then
DoCmd.SetWarnings False
Form.RecordSource = "SELECT tblEmployees.* FROM tblEmployees;"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.GoToRecord , , acNewRec
Err_BNEW1_Click:
On Error Resume Next
DoCmd.GoToRecord , , acNewRec
Me.Employee_ID.SetFocus
End If
End Sub
انتظر مساعدتكم