I have a database that has a button on the record form that will create folder using the record number using the following code:
and uses the following code to open the folder relating to the record number:
I want to be able to add an image to the form by browsing to the record related folder and selecting an image so all relevant information is contained in the same folder. At the moment I have a code attached to a button which works well and allows me to browse and link the photo, but it just opens up a standard Explorer window which I then have to navigate around to find the folder correlating to the record number. Is there a way to open directly to the record specific folder to link the Image to minimise the need for navigating? The current browse for image code is below:
Code:
Private Sub CreateFolder_Click()
' In Microsoft Windows:
' Specifying 1 as the second argument opens the application in
' normal size and gives it the focus.
Dim RetVal
Dim FolderName As String
FolderName = Format(Me.Job_Number, "00000")
RetVal = Shell("cmd.exe /C color 4e && md G:\Jobs\" & FolderName, 1) ' Create graphics Job folder.
MsgBox "The folder G:\Jobs" & FolderName & " has been created. You should use this folder to store all files related to this finished Job. When the job is complete ensure you clear up any other files stored on the network, so as to conserve storage space.", vbOKOnly, "Folder Created"
End Sub
and uses the following code to open the folder relating to the record number:
Code:
Private Sub View_Folder_Click()
Dim RetVal
Dim FolderName As String
FolderName = Format(Me.Job_Number, "00000")
RetVal = Shell("explorer G:\Jobs\" & FolderName, 1) ' View Job folder
Code:
Private Sub BrowseImge_button_Click()
Dim f As Object
Dim strfile As String
Dim strfolder As String
Dim VarItem As Variant
Set f = Application.FileDialog(3)
f.allowMultiSelect = True
If f.Show Then
For Each VarItem In f.selectedItems
strfile = Dir(VarItem)
strfolder = Left(VarItem, Len(VarItem) - Len(strfile))
MsgBox "Folder" & strfolder & vbCrLf & "File: " & strfile
Image_Source_TXT = strfolder + strfile
Next
End If
End Sub