ممتاز ، جرب هذا التعديل الآن من خلال الكود التالي للزر :-
Private Sub Update_takhrij_Click()
Dim db As DAO.Database
Dim rsSource As DAO.Recordset
Dim rsTarget As DAO.Recordset
Dim sourceTable As String
Dim mnoFields As Variant
Dim i As Integer
Dim currentMNO As String
On Error GoTo ErrHandler
Set db = CurrentDb
sourceTable = Me.txt1.Value
mnoFields = Array("MNO", "MNO2", "MNO3", "MNO4", "MNO5", "MNO6", "MNO7")
Set rsSource = db.OpenRecordset("SELECT * FROM [" & sourceTable & "]", dbOpenSnapshot)
Set rsTarget = db.OpenRecordset("TAB_takhrij_X", dbOpenDynaset)
Do While Not rsSource.EOF
For i = 0 To UBound(mnoFields)
currentMNO = Trim(Nz(rsSource(mnoFields(i)), ""))
If currentMNO <> "" Then
rsTarget.AddNew
rsTarget!bookID = CStr(rsSource!bookID)
rsTarget!TableNo = CLng(rsSource!TableNo)
rsTarget!MNO = currentMNO
rsTarget.Update
End If
Next i
rsSource.MoveNext
Loop
rsSource.Close
rsTarget.Close
Set rsSource = Nothing
Set rsTarget = Nothing
Set db = Nothing
MsgBox "تم حفظ الأحاديث بنجاح", vbInformation + vbMsgBoxRight, ""
Exit Sub
ErrHandler:
MsgBox "حدث خطأ", vbCritical + vbMsgBoxRight, ""
End Sub
الملف :-
takhrij.zip