Yatiman Idara
Registered User.
- Local time
- Today, 02:00
- Joined
- Apr 22, 2016
- Messages
- 27
Hi everyone
I do apologize for asking too many questions over the last few days but I am almost in the final stages of my program and navigating unchartered territory
Basically I have set up a simple function for displaying images.
I have stored the imagepath in a text field and then used an image control (with controlsource set to the field containing the image path)
What i would like now is to set up the following ability:
Customer double clicks on the imagecontrol. File Dialog opens up. They browse to the folder containing the pictures (obviously filter to only show image formats would be nice) and select the image file relating to that record.
The path of this selected image is retrieved and stored as the new value of the imagepath field.
I have seen a few functions to achieve this but they appear too complicated. I think it might be possile to achieve this by simply using a FileDialog. I found this one function on from a sample and tampered around with it but with no success. Sample code is below:
'Opens a File Dialog Picker window and returns the full path of the selected file
Function SelectFile(Optional ByVal Filter As Integer = 1, _
Optional ByVal title As String = "Select file") As String
Dim fso As Object
Set fso = CreateObject("scripting.filesystemobject")
With Application.FileDialog(3) '3 = msoFileDialogFolderPicker
.title = title
.AllowMultiSelect = False
Select Case Filter
Case 1
.Filters.Clear
Case 2
.Filters.Add "Access", "*.bmp; *.jpg; *.png; *.accde", 1
Case 3
.Filters.Add "Excel", "*.xls", 1
Case 4
.Filters.Add "Text", "*.txt", 1
Case 5
.Filters.Add "CSV", "*.csv", 1
End Select
If .Show = -1 Then
SelectFile = fso.GetFile(Application.FileDialog(4).SelectedItems(1)) '4 = msoFileDialogFolderPicker
Else
GoTo finalize
End If
End With
finalize:
Set fso = Nothing
End Function
Any help would be appreciated
I do apologize for asking too many questions over the last few days but I am almost in the final stages of my program and navigating unchartered territory

Basically I have set up a simple function for displaying images.
I have stored the imagepath in a text field and then used an image control (with controlsource set to the field containing the image path)
What i would like now is to set up the following ability:
Customer double clicks on the imagecontrol. File Dialog opens up. They browse to the folder containing the pictures (obviously filter to only show image formats would be nice) and select the image file relating to that record.
The path of this selected image is retrieved and stored as the new value of the imagepath field.
I have seen a few functions to achieve this but they appear too complicated. I think it might be possile to achieve this by simply using a FileDialog. I found this one function on from a sample and tampered around with it but with no success. Sample code is below:
'Opens a File Dialog Picker window and returns the full path of the selected file
Function SelectFile(Optional ByVal Filter As Integer = 1, _
Optional ByVal title As String = "Select file") As String
Dim fso As Object
Set fso = CreateObject("scripting.filesystemobject")
With Application.FileDialog(3) '3 = msoFileDialogFolderPicker
.title = title
.AllowMultiSelect = False
Select Case Filter
Case 1
.Filters.Clear
Case 2
.Filters.Add "Access", "*.bmp; *.jpg; *.png; *.accde", 1
Case 3
.Filters.Add "Excel", "*.xls", 1
Case 4
.Filters.Add "Text", "*.txt", 1
Case 5
.Filters.Add "CSV", "*.csv", 1
End Select
If .Show = -1 Then
SelectFile = fso.GetFile(Application.FileDialog(4).SelectedItems(1)) '4 = msoFileDialogFolderPicker
Else
GoTo finalize
End If
End With
finalize:
Set fso = Nothing
End Function
Any help would be appreciated