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
239 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

856 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