اليك هذا الكود ... يعمل لك فولدر ان لم يكن موجود في مسار القاعدة وايضا باسم الموظف او اي شي انت تحدده.
الكود للامانة لاحد الاساتذة مع بعض التعديلات البسيطة ... للاسف لا اعرف من هو جزاه الله كل الخير.
لقد جربت الكود الان وهو يعمل بشكل صحيح ..لا تنسى تغير اسماء الحقول
On Error GoTo err:
Dim Fs, Cf, strFolder
Const msoFileDialogFilePicker As Long = 3
Dim objDialog As Object
Set objDialog = Application.FileDialog(msoFileDialogFilePicker)
strFolder = CurrentProject.Path & "\" & "Image"
Set Fs = CreateObject("Scripting.FileSystemObject")
If Fs.FolderExists(strFolder) = False Then
Set Cf = Fs.CreateFolder(strFolder)
If Fs.FolderExists(strFolder) = True Then
MsgBox "'" & strFolder, vbInformation, "' تم انشاء المجلد في المسار التالي "
Else
MsgBox "'" & strFolder, vbExclamation, "'لم يتم انشاء المجلد"
End If
End If
If IsNull([Names]) Or [Names] = Null Or [Names] = "" Then
[Names].SetFocus
MsgBox "من فضلك يجب كتابة الاسم أولا حتى تتمكن من إضافة صورة", vbInformation, "يجب كتابة الاسم"
Exit Sub
End If
Dim fso As Object
Set fso = CreateObject("scripting.filesystemobject")
Dim varFile As Variant
Dim destpath As Variant
Me.Image = ""
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False
.Title = "رجاءً قم بتحديد مكان الصورة"
.Filters.Clear
.Filters.Add "png image", "*.png"
.Filters.Add "jpg image", "*.jpg"
.Filters.Add "jpeg image", "*.jpeg"
.Filters.Add "All Files", "*.*"
If .show = True Then
For Each varFile In .SelectedItems
destpath = Application.CurrentProject.Path & "\" & "Image" & "\" & Me.Names & "f." & Right$(varFile, Len(varFile) - InStrRev(varFile, "."))
FileCopy varFile, destpath
Me.Image = destpath
Me.Refresh
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
Exit Sub
err:
MsgBox err.Description & " " & err.Number
وافنا بالنتيجة.
بالتوفيق