Results 1 to 15 of 15
  1. #1
    Join Date
    Aug 2006
    Posts
    559

    Unanswered: "Browse" button for attachments

    I've created the email form in the database but want to add a 'browse' button so that users can attach a file, if needs be, to the email. I've got the textbox for where the complete path of the file will be displayed, I just can't figure out how to create a 'browse' button which would allow a user to search the machine for their desired attachment (much like an "open file" / "save as" dialog box).

    Any idears?

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    I think you're referring to a Common Dialog API, check microsoft's site.
    Me.Geek = True

  3. #3
    Join Date
    Aug 2006
    Posts
    559
    Hmm...I'll take a look at it.

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You can also take a look at the Access 2000 Developer's Handbook (Volume 1) by Litwin-Getz-Gilbert (Chapter 11 and Chapter 17) which have very good examples in an mdb on how to do this (especially Chapter 17 which is exactly what you want - frmTestFileOpenSave and frmTestOfficeFileOpen.)
    Last edited by pkstormy; 06-26-07 at 17:04.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Aug 2006
    Posts
    559
    Quote Originally Posted by pkstormy
    You can also take a look at the Access 2000 Developer's Handbook (Volume 1) by Litwin-Getz-Gilbert (Chapter 11 and Chapter 17) which have very good examples in an mdb on how to do this (especially Chapter 17 which is exactly what you want - frmTestFileOpenSave and frmTestOfficeFileOpen.)

    Wish they still carried this book at Barnes&Nobels! I can't find it anywhere.

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Amazon.com still has them. I would highly suggest investing in a copy (it's well worth it for all the sample code you get on the cd!) I believe you can also subscribe to the book, notes, and samples online from their website. I'll see if I can dig up the link.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    This link might also help...it has a sample of CommonDialog box code.

    http://www.trevor.easynet.co.uk/AccFAQ/general.htm
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What's wrong with using a good old fashioned FSO?
    I believe I posted it up here for you a while ago PK... Far easier to implement, understand and customize (in my eyes anyway!).
    George
    Home | Blog

  9. #9
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    If you're talking about the threads on the Dir function, here's the link http://www.dbforums.com/showthread.php?t=1619287. I forgot about this - sorry George (overworked.) I had the Access 2000 Developer (Version 1) on my lap at the time so it was the first thing that popped into my head and I didn't bother thinking past that.

    Bryan,

    You should look at these threads and George's code.

    George,

    Also, FYI, I had to add in the Microsoft Office 10 Object Library reference to use this code.
    Last edited by pkstormy; 06-26-07 at 21:03.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by pkstormy
    George,

    Also, FYI, I had to add in the Microsoft Office 10 Object Library reference to use this code.
    Post 24 in the above thread...
    http://www.dbforums.com/showpost.php...3&postcount=24
    George
    Home | Blog

  11. #11
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I responded too quickly again.

    George,
    Is this Object Library available if the users only have MSAccess?
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  12. #12
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    OOh, now that is a good question.
    The name certainly suggests that it might be Office package specific.
    There's an explicit Access Library that may be worth a look in.
    This may be useful: http://www.dbforums.com/showpost.php...7&postcount=16
    George
    Home | Blog

  13. #13
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    This is some code that will pop up a window for the user to browse to the text file they want to link to:

    Code:
        Dim dlgBrowse As FileDialog
        Dim strPath As String
        Dim strFilename As String
        
        Set dlgBrowse = Application.FileDialog(msoFileDialogFilePicker)
        strPath = "M:\Clients\Scrip\Files\Orders\"
        
        MsgBox "Select the newly create Scrip file with this week's data in it.", vbOKOnly + vbInformation
        
        With dlgBrowse
            
            '.Filters.Add "Text Files", "*.txt"
            .AllowMultiSelect = False
            .InitialFileName = strPath
            .Show
            
            If .SelectedItems.Count <> 0 Then
    
                strFilename = .SelectedItems(1)
                
                On Error Resume Next
                DoCmd.DeleteObject acTable, "tblIncomingOrders"
                On Error GoTo 0
                
                DoCmd.TransferText acLinkDelim, "Link-Scrip-Order-20060104", "tblIncomingOrders", strFilename
                
            End If
            
        End With
        
        Set dlgBrowse = Nothing
    You will need to link to the Microsoft Office x.0 Object Library (10 for Access 2002) to use the FileDialog object.

  14. #14
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I've added something to the code library which you may want to take a look at; linky
    George
    Home | Blog

  15. #15
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by pkstormy
    George,
    Is this Object Library available if the users only have MSAccess?
    Had a look int this today - it appears that the Office library is the only one that works (not a guarentee ). Unfortunately I can't check this because I have Office installed, not just the one component.

    If anyone has only got Access installed can you please test [URL=http://www.dbforums.com/showpost.php?p=6280858&postcount=35this[/URL] and let us know how you get on / any errors etc!
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •