Solved

How do I create a button on an Access form that let's the user browse to a file and save it to a folder defined in a form field?

Posted on 2014-09-25
6
229 Views
Last Modified: 2014-10-27
I have a form where users can create a new record. This record is associated with a file on the server. Instead of them creating a record and then having to go to the server and save it all manual like, I thought I'd let them click a button, browse to the file on the flash drive, and save it to the folder that's in a form field on the form.  So let's say they're creating a new record and choose C1 as the directory. They fill in the info, then click a button that says "save file to the server." This opens the window and let's them browse to the file. They click the file and it saves it to the C1 directory.

It's basically just saving a file to the server, but it keeps them from having to create a record, then going into windows explorer, copying, blah blah blah (plus it can allow me to force them to use the program instead of putting the file on the server and not creating a record for it).
0
Comment
Question by:Kevin Smith
6 Comments
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
This is the help entry to the FileDialogFilePicker for Access 2013.  It should work as far back as A2007 and possibly earlier.  The code opens the standard file dialog which lets the user browse to a folder and select one or more files.  You can control whether or not to allow multi-select.

http://msdn.microsoft.com/en-us/library/office/ff196794(v=office.15).asp
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
Comment Utility
Or you can import the attached module with ready-to-go functions:

    strFile = SaveFileNameDlg("Test", "Export File (*.txt)|*.txt", "c:\Temp", "file.txt")

It doesn't require a reference to anything.

/gustav
basFileDialogue.bas
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 31

Expert Comment

by:Helen_Feddema
Comment Utility
Something is missing here.  You speak of creating a new record, which would be a record in an Access table, but then of browsing for a file on a flash drive.  If the file is already there, how does that relate to the new table record?  If you are creating a text file from VBA code, say using components of the FileSystemObject, then you can save it to the folder path picked up from the form, no need to browse for anything.

BTW, I can confirm that the FilePicker and FolderPicker dialogs work fine in Access 2003 and up -- the FileDialog object was introduced in Office XP (Access 2002).
0
 

Author Closing Comment

by:Kevin Smith
Comment Utility
Thanks to everyone for your help!
0
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
You are welcome!

/gustav
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now