I have a textbox on my form that has an event handler (on click) associated with it. The macro that launches is supposed to open a file dialog box and capture what the user selects. The forms can then use that file path to display a picture to assist in generating a section of a report.
Private Sub Defect1_Click()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
With fd
.AllowMultiSelect = False
.Title = "Browse to Select a File"
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
MsgBox "Selected item's path: " & vrtSelectedItem
Me.DefectPhoto1.Value = vrtSelectedItem
Next
End If
End With
Set fd = Nothing
Form.Refresh
End Sub
When clicked, I immediately get an error message on the statement above in bold. It tells me the method or data member not found. I have used this construction before with no issues and was curious if anyone could decipher the issue with this syntax. The field "DefectPhoto1" is intended to be short text field, so the issue may be with the ".Value" syntax since that would imply a number? But if not a number, what would go there, or do I have this screwed up to begin with?
Thanks for taking the time look!
Private Sub Defect1_Click()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
With fd
.AllowMultiSelect = False
.Title = "Browse to Select a File"
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
MsgBox "Selected item's path: " & vrtSelectedItem
Me.DefectPhoto1.Value = vrtSelectedItem
Next
End If
End With
Set fd = Nothing
Form.Refresh
End Sub
When clicked, I immediately get an error message on the statement above in bold. It tells me the method or data member not found. I have used this construction before with no issues and was curious if anyone could decipher the issue with this syntax. The field "DefectPhoto1" is intended to be short text field, so the issue may be with the ".Value" syntax since that would imply a number? But if not a number, what would go there, or do I have this screwed up to begin with?
Thanks for taking the time look!