I am trying to allow users to add attachments to a defect record. This will allow them to select photo or documents from their computer then name and save them to a central folder. I have this so far. When clicked, I get the message box, but then it throws "The expression you entered has an invalid reference to the Parent property." on the Set Dlg line.
Code:
Private Sub cmdAttach_Click()
Dim Dlg As Object
Dim txtFilePath As String
Dim vrtSelectedItem As Variant
MsgBox ("To attach supporting documents to this Defect Report, please select from the next window. (NOTE: Multiple files may be attached by holding Ctrl and selecting the desired files.")
Set Dlg = Application.FileDialog(msoFileDialogFilePicker)
With Dlg
.Title = "Select the document(s) you want to attach."
.AllowMultiSelect = True
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
'vrtSelectedItem is a Variant that contains the path of each selected item
Me.lstAttach.AddItem (vrtSelectedItem)
Next vrtSelectedItem
Else
Exit Sub
End If
End With
End Sub
Any help would be greatly appreciated.