If you are using images frequently and saving them as attachments in MS Access database, you might end up with a heavy file. The software has also a limit of 2GB file size. To avoid that situation, you may like to save your images in a separate folder and display them in the database by a text path. Through the following example, I will show you how to do it.
The example has a table and a form with the fields: ID (auto number) and Path (text). There are two more elements on the form: BrowseTo button and Image frame. When a user clicks on BrowseTo button, it will browse to a file and save its path in the field Path. If the file is an image, it will be displayed in the frame Image.
After creating all the required elements, right-click on BrowseTo button, go to Properties > Event > On Click, select [Event Procedure] and click on ellipses (three dots) to open VB application. Select the code area and paste the following code:
Private Sub cmdBrowseTo_Click()
Dim fdg As FileDialog, vrtSelectedItem As Variant
Dim strSelectedFile As String
Set fdg = Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.InitialView = msoFileDialogViewDetails
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
strSelectedFile = vrtSelectedItem
Me![Path] = strSelectedFile
Set fdg = Nothing
Stay in the VB application, go to the menu Tools > References and check Microsoft Office xx.x Object Library.
Before testing the button, right-click on the frame Image, go to Properties > Data > Control Source and select Path, so that it can display the image through the path.