كود :
On Error Resume Next: Err.Clear
If Val(Trim$(Text1.Text)) <= 0 Then
MsgBox "تأكد من صحة الرقم", vbOKOnly + vbExclamation, "تنبيه"
Text1.SetFocus
Exit Sub
End If
Text6.Locked = True
MSHFlexGrid1.Enabled = False
EnabledOrDisbled_MainButtons False, False, False, False, True
EnabledOrDisbled_MovingButtons False, False, False, False
If RA.State = 1 Then RA.Close
RA.Open "Select * From Mobachir Where [الرقم]=" & Val(Trim$(Text1.Text)), DB, adOpenStatic, adLockPessimistic
If RA.RecordCount <= 0 Then
If RA.State = 1 Then RA.Close
MsgBox "لم يتم العثور على هذا السجل في قاعدة البيانات!", vbOKOnly + vbExclamation, "تنبيه"
Text6.Locked = False
MSHFlexGrid1.Enabled = True
EnabledOrDisbled_MainButtons True, False, True, True, True
EnabledOrDisbled_MovingButtons True, True, True, True
Text1.SetFocus
Exit Sub
End If
If MsgBox("هل تريد بالتأكيد حذف هذا السجل؟", vbOKOnly + vbYesNo + vbExclamation, "") = vbNo Then
Text6.Locked = False
MSHFlexGrid1.Enabled = True
EnabledOrDisbled_MainButtons True, False, True, True, True
EnabledOrDisbled_MovingButtons True, True, True, True
Text1.SetFocus
Exit Sub
End If
'نسخ السجل للارشيف قبل حذفه
Dim ra2 As New ADODB.Recordset
If ra2.State = 1 Then ra2.Close
sql = "INSERT INTO Archives SELECT Mobachir.* FROM Mobachir WHERE (((Mobachir.الاسم)=" & "'" & Trim(Text2.Text) & "'))"
ra2.Open sql, DB, adOpenStatic, adLockPessimistic
'ra2.Close
Set ra2 = Nothing
RS.Delete
DoEvents
Clear_TextBoxs
LockOrUnLock_TextBoxs True
Text6.Locked = False
MSHFlexGrid1.Enabled = True
If RS.RecordCount > 0 Then
Command8_Click
EnabledOrDisbled_MainButtons True, False, True, True, True
EnabledOrDisbled_MovingButtons True, True, True, True
Else
EnabledOrDisbled_MainButtons True, False, False, False, True
EnabledOrDisbled_MovingButtons False, False, False, False
End If
View_Records
Is_EditMode = False
DrawFlex
Text1.SetFocus