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
235 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 35

Expert Comment

by:PatHartman
ID: 40344265
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
ID: 40344311
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40345561
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 40346090
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
ID: 40406743
Thanks to everyone for your help!
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40406748
You are welcome!

/gustav
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

777 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