الدالة تصبح
Function RelinkIsIco() As String
Dim rs As DAO.Recordset
Dim rsA As DAO.Recordset2
Dim fPath As String
Dim tempPath As String
' فتح السجل
Set rs = CurrentDb.OpenRecordset("SELECT progIcon FROM tblEnDc")
If Not (rs.EOF And rs.BOF) Then
Set rsA = rs.Fields("progIcon").Value ' Recordset خاص بالمرفقات
If rsA.RecordCount > 0 Then
rsA.MoveFirst
' تحديد مسار مؤقت في Windows Temp
tempPath = Environ$("TEMP") & "\" & rsA!FileName
' استخراج الملف من المرفقات إلى المسار المؤقت
rsA!FileData.SaveToFile tempPath
RelinkIsIco = tempPath
End If
rsA.Close
End If
rs.Close
Set rs = Nothing
End Function
واستدعاؤها
Private Sub cmdShar_Click()
Me.img1.Picture = RelinkIsIco()
End Sub