I added a button to browse and store the photo name and location to a table
When i click button it opens the VBA Code. I tried running it and get "Macro Export Query Name" pop up. The button does not select. tblPlantInspection hs the following columns:
Code:
CREATE TABLE tblPlantInspection ( [InspectionID] AUTOINCREMENT PRIMARY KEY,
[PlantID] TEXT(50) NOT NULL,
[InspectionDate] DATETIME,
[DiseaseStatus] TEXT(50),
[PestPresence] YESNO,
[NutrientDeficiency] YESNO,
[Comments] MEMO,
[PhotoPath] TEXT(255),
[ReportPath] TEXT(255)
);

Pls assist with a VBS Code that will give me this function

Code:
Private Sub btnOpenPhoto_Click() On Error GoTo Err_OpenPhoto
If Not IsNull(Me.txtPhotoPath) And Me.txtPhotoPath <> "" Then
Application.FollowHyperlink Me.txtPhotoPath
Else
MsgBox "No photo available to open.", vbExclamation, "Error"
End If
Exit Sub
Err_OpenPhoto:
MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation, "Open Photo Error"
Resume Next
End Sub
https://drive.google.com/file/d/1I5F...usp=drive_link
This code opens selection, but i cant see any media files:
Code:
Private Sub btnBrowsePhoto_Click() Dim fd As Object
Dim strFile As String
' Open File Dialog
Set fd = Application.FileDialog(3) ' 3 = File Picker
With fd
.Title = "Select a Photo File"
.Filters.Clear
.Filters.Add "All Image Files", "*.jpg; *.jpeg; *.png; *.bmp; *.gif; *.tif; *.tiff"
.AllowMultiSelect = False
' If the user selects a file, store its path
If .Show = -1 Then
strFile = .SelectedItems(1)
Me.Controls("PhotoPath").Value = strFile ' Fix applied here
End If
End With
' Cleanup
Set fd = Nothing
End Sub