Results 1 to 9 of 9
  1. #1
    dccjr3927 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    130

    Add attachemnts to record

    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.

  2. #2
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Are you using Dlg as a subform? Or is it the main form?

  3. #3
    dccjr3927 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    130
    It is suppose to open the system File Picker window similar to the File Open window. I guess it would be a subform at that point.

  4. #4
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Which form is the button located to open the file picker?

  5. #5
    dccjr3927 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    130
    It is located on frmDefectracking.

  6. #6
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Do you have a reference set to the Microsoft Office XX object library?

  7. #7
    dccjr3927 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    130
    No. Where and how would I add it?

  8. #8
    dccjr3927 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    130
    Got it. Thank you very much.

  9. #9
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Quote Originally Posted by dccjr3927 View Post
    Got it. Thank you very much.
    Glad I could be of assistance :-)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 08-18-2018, 10:23 AM
  2. Replies: 4
    Last Post: 10-21-2017, 09:56 AM
  3. Replies: 4
    Last Post: 01-12-2016, 02:49 PM
  4. Replies: 3
    Last Post: 03-09-2013, 10:39 AM
  5. Replies: 2
    Last Post: 12-21-2012, 01:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums