Results 1 to 10 of 10
  1. #1
    michaeljohnh is offline More Human than Human
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    61

    Browse to external file while in a form

    I have made a database that is used for ticket tracking on a help desk.



    Here's what I have accomplished. When a new ticket is being written, I currently have a field where the tech can paste the path of the file the tech wishes to upload (i.e. a screenshot of an error message). They then hit a button and it sucessfully saves that file to the network drive so it is accesible to the Tier II tech support if the ticket is not resolved and gets escalated.

    What I want to do is rather than having the tech copy and paste the path into the field, is there a way to have the default Windows file browser open so the tech can just browse to the file they want to upload?

    If so what would the code look like for the opening of the file browser and the handling of the file selected. I can handle the saving of the file to the network drive.

    Thanks in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,043
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    michaeljohnh is offline More Human than Human
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    61
    I gave that a try but got the following error. I copied and pasted the entire code into the On Click event of a button and didnt make any changes. Is there a stripped down version that does the bare minimum of opening the file browser and captures the file name and path? I dont need any other bells or whistles. I can handle the uploading to the network drive myself. That way, I would be far more likely to be able to troubleshoot. I looked over the code and really didnt even know where to begin.

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,043
    That's not how you want to use it. Copy everything from "code start" to "code end" into a new standard module. Name the module "basCommDialog" (it doesn't actually have to be named that, but it can't be named the same as any of the functions within). Then you simply call it to populate a string variable as in the example before "code start". Here's an example from one of mine (which I borrowed from somebody else):

    Code:
    Function fGetMDBName(strIn As String) As String
    'Calls GetOpenFileName dialog
    Dim strFilter As String
    
        strFilter = ahtAddFilterItem(strFilter, _
                        "Access Database(*.mdb;*.mda;*.mde;*.mdw; *.accdb;*.accde) ", _
                        "*.mdb; *.mda; *.mde; *.mdw; *.accdb;*.accde")
        strFilter = ahtAddFilterItem(strFilter, _
                        "All Files (*.*)", _
                        "*.*")
    
        fGetMDBName = ahtCommonFileOpenSave(Filter:=strFilter, _
                                    OpenFile:=True, _
                                    DialogTitle:=strIn, _
                                    Flags:=ahtOFN_HIDEREADONLY)
    End Function
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    michaeljohnh is offline More Human than Human
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    61
    I created a module using the entire code named basCommDialog. In the OnClick event of the button I want to use to open the file selector I placed the following code :

    Private Sub Command61_Click()
    DoCmd.OpenModule basCommDialog
    End Sub

    If this incorrect, I am uncertain how else to "call it".

    I get the below error.

    Thank you for your continuing assistance.

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,043
    You call it like this:

    Code:
    Private Sub Command61_Click()
    Dim strFilter As String 
    Dim strPath as String
    
        strFilter = ahtAddFilterItem(strFilter, _
                        "Access Database(*.mdb;*.mda;*.mde;*.mdw; *.accdb;*.accde) ", _
                        "*.mdb; *.mda; *.mde; *.mdw; *.accdb;*.accde")
        strFilter = ahtAddFilterItem(strFilter, _
                        "All Files (*.*)", _
                        "*.*")
    
        strPath = ahtCommonFileOpenSave(Filter:=strFilter, _
                                    OpenFile:=True, _
                                    DialogTitle:="Find your file", _
                                    Flags:=ahtOFN_HIDEREADONLY)
    
       'do what you want with strPath  
    End Sub
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    michaeljohnh is offline More Human than Human
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    61
    Thank you very much for your assistance the dialog window is opening now and I can browse to files.

    I take it strPath stores the path and file name selected?

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,043
    It's a variable that contains the path and file name. You have to do something with it; it will not be stored anywhere once the procedure ends otherwise.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    michaeljohnh is offline More Human than Human
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    61
    Working like a charm, thank you very much. I gave your rep a boost, hopefully you'll level up .

  10. #10
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,043
    Glad we got it working for you.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 4
    Last Post: 05-20-2010, 03:49 AM
  2. A way to force Access to update external file?
    By gkun in forum Import/Export Data
    Replies: 0
    Last Post: 10-27-2009, 06:11 PM
  3. Using data in external file for conditional processing
    By jkellygarrett in forum Import/Export Data
    Replies: 0
    Last Post: 09-17-2009, 01:01 PM
  4. Browse for file
    By ccpine@comcast.net in forum Database Design
    Replies: 0
    Last Post: 08-24-2008, 10:12 AM
  5. Browse Option
    By emilylu3 in forum Access
    Replies: 1
    Last Post: 01-10-2006, 09:46 AM

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