السلام عليكم
اخواني لدي مشكل ببرنامجي وهو خاص بالموظفين
المشكل هو عند حفظ صورة لموظف ما وتريد تغييرها بعد ذلك يعطي أن هناك تكرار وعند حذف الدالة Rs.AddNew فان عملية الحفظ لا تتم
مع أن اذا قمت بعمل ادخال بيانات جديدة فان عملية الحفظ تتم بشكل جيد لكن المشكلة وهو في التعديل على الصورة مع البيانات
الكود
Private Sub SavePicture(Pic_FileName As String)
Dim F As Long
Dim Pic_FileLength As Long
Dim Pic_Bytes() As Byte
On Error Resume Next
If dRS.State = 1 Then dRS.Close
dRS.CursorLocation = adUseClient
dRS.Open "SELECT * FROM Pic", CN, adOpenKeyset, adLockOptimistic
If Trim(Pic_FileName) <> "" Then
If Dir$(Pic_FileName) <> "" Then
F = FreeFile
DoEvents
Open Pic_FileName For Binary As #F
DoEvents
Pic_FileLength = LOF(F)
DoEvents
ReDim Pic_Bytes(Pic_FileLength)
DoEvents
Get #F, , Pic_Bytes()
DoEvents
Close #F
DoEvents
dRS.Fields("Image").AppendChunk Pic_Bytes()
DoEvents
dRS![Size] = Pic_FileLength
DoEvents
dRS![Matricule] = Text1
dRS![Nom] = Text2
dRS![Prénom] = Text3
dRS![Adresse] = Text4
dRS![CP] = Text5
dRS![ville] = Text6
dRS![Téléphone] = Text7
dRS![DateNaissance] = Text8
dRS![LieuNaissance] = Text9
dRS![EtatMatrimonial] = Text10
dRS![NombreDenfants] = Text11
dRS![CIN] = Text12
dRS![DateEntrée] = Text13
dRS![DateSortie] = Text14
dRs.updateوكود الاستدعاء
Dim F As Long
Dim Pic_FileLength As Long
Dim Pic_Bytes() As Byte
Image2.Picture = Nothing
'If TB.State = 1 Then TB.Close
'TB.CursorLocation = adUseClient
'TB.Open "SELECT * FROM Products", DB, adOpenStatic, adLockReadOnly
On Error Resume Next
If Not IsNull(dRS![Matricule]) Then Text1 = dRS![Matricule]
If Not IsNull(dRS![Nom]) Then Text2 = dRS![Nom]
If Not IsNull(dRS![Prénom]) Then Text3 = dRS![Prénom]
If Not IsNull(dRS![Adresse]) Then Text4 = dRS![Adresse]
If Not IsNull(dRS![CP]) Then Text5 = dRS![CP]
If Not IsNull(dRS![ville]) Then Text6 = dRS![ville]
If Not IsNull(dRS![Téléphone]) Then Text7 = dRS![Téléphone]
If Not IsNull(dRS![DateNaissance]) Then Text8 = dRS![DateNaissance]
If Not IsNull(dRS![LieuNaissance]) Then Text9 = dRS![LieuNaissance]
If Not IsNull(dRS![EtatMatrimonial]) Then Text10 = dRS![EtatMatrimonial]
If Not IsNull(dRS![NombreDenfants]) Then Text11 = dRS![NombreDenfants]
If Not IsNull(dRS![CIN]) Then Text12 = dRS![CIN]
If Not IsNull(dRS![DateEntrée]) Then Text13 = dRS![DateEntrée]
If Not IsNull(dRS![DateSortie]) Then Text14 = dRS![DateSortie]
If Not IsNull(dRS![NCNSS]) Then Text15 = dRS![NCNSS]
If Not IsNull(dRS![NiveauDetudes]) Then Text16 = dRS![NiveauDetudes]
If Not IsNull(dRS.Fields("Image")) Then
On Error Resume Next
If Dir$(App.Path & "\TempPic.bmp") <> "" Then Kill App.Path & "\TempPic.bmp"
F = FreeFile
Open App.Path & "\TempPic.bmp" For Binary As #F
Pic_FileLength = dRS![Size]
Pic_Bytes() = dRS.Fields("Image").GetChunk(Pic_FileLength)
Put #F, , Pic_Bytes()
DoEvents
Close #F
If Dir$(App.Path & "\TempPic.bmp") <> "" Then Set Image2.Picture = LoadPicture(App.Path & "\TempPic.bmp")
If Dir$(App.Path & "\TempPic.bmp") <> "" Then Kill App.Path & "\TempPic.bmp"
End If
Oks:ارجو مساعدتكم في أقرب وقت
وشكرا
