473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Folder Dialog box with Make New Folder option

489 256MB
In my application I have an option to backup the data it creates a .txt file for each table. I'm using some old code that is quite lengthy and was created for access 2002. I would like to see if there is some new code. I want the user to be able to select from a standard windows dialog box, select a given folder but I would like to have the user be able to also be able to make a new folder. When the folder is either selected or a new folder is created the data from the tables will be entered into the selected folder. I'm using the standard DoCmd.TransferText to export the data.
Like I mentioned the code I'm using now works fine but it is very large and takes some time to work.
I've been looking at some of the code and lots of the Folder Dialog is quite small and brings up the standard dialog box but there is no option to make a folder.
Thanks for any help.
Jan 25 '16 #1

✓ answered by MikeTheBike

Hi

I tend to use this when I need to select a folder/file
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Sub SelectFolder()
  5.     Dim fd As FileDialog
  6.     Dim strFolder As String
  7.  
  8.     Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  9.     With fd
  10.         .AllowMultiSelect = False
  11.         If .Show = -1 Then
  12.             strFolder = .SelectedItems(1)
  13.             MsgBox strFolder
  14.         End If
  15.     End With
  16. End Sub
I am currently on Access 2007, the above code opens a standard dialogue box that includes an add 'New Folder' button.

This code requires a reference to the Microsoft Office Object Library.

This will obviously need amending to suit your purpose.

HTH

MTB

8 3003
MikeTheBike
639 Expert 512MB
Hi

I tend to use this when I need to select a folder/file
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Sub SelectFolder()
  5.     Dim fd As FileDialog
  6.     Dim strFolder As String
  7.  
  8.     Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  9.     With fd
  10.         .AllowMultiSelect = False
  11.         If .Show = -1 Then
  12.             strFolder = .SelectedItems(1)
  13.             MsgBox strFolder
  14.         End If
  15.     End With
  16. End Sub
I am currently on Access 2007, the above code opens a standard dialogue box that includes an add 'New Folder' button.

This code requires a reference to the Microsoft Office Object Library.

This will obviously need amending to suit your purpose.

HTH

MTB
Jan 26 '16 #2
CD Tom
489 256MB
I like the looks of this dialog but it seems to be wanting me to type in a file name, I'm adding about 20 files with different name and the extension .txt After I select the folder I just want the files to be put in the selected folder.
Jan 26 '16 #3
MikeTheBike
639 Expert 512MB
The routine I posted is purely to illustrate how to pick/create a folder and return its path to the program/code.
You will need to write some code to loop through the list of items you want to save using the folder path and the DoCmd.TransferText you have suggested.

Cannot help too much with that as I never use DoCmd.Transer.... command to save info to disc/network, but I am sure there other more capable then I that can.


MTB
Jan 26 '16 #4
ADezii
8,834 Expert 8TB
The following Demo using the Windows Browse For Folder Dialog will allow you to either Select an existing Folder or create a New Folder. The Fully Qualified PATH to this Folder will be contained in varRet. After retrieving this Folder it will be a simple matter to Transfer Data to it.
Attached Files
File Type: zip Demo.zip (19.6 KB, 156 views)
Jan 26 '16 #5
CD Tom
489 256MB
My error in the set fd I picked the file picker instead of the folder picker. That works great thanks, this is much less code.
Jan 26 '16 #6
CD Tom
489 256MB
Just a quick question is there a way to tell the dialog box to highlight a start folder? Say I want the dialog box to start with a folder called c:\backups
Thanks
Jan 26 '16 #7
MikeTheBike
639 Expert 512MB
Expand|Select|Wrap|Line Numbers
  1. Sub SelectFolder()
  2.     Dim fd As FileDialog
  3.     Dim strFolder As String
  4.  
  5.     Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  6.     With fd
  7.         .InitialFileName = "c:\backups"
  8.         .AllowMultiSelect = False
  9.         If .Show = -1 Then
  10.             strFolder = .SelectedItems(1)
  11.             MsgBox strFolder
  12.         End If
  13.     End With
  14. End Sub
Just use the .InitialFileName property as above.
There are other properties/methods you can use. Just use the IntelliSense on the dialogue object.

HTH


MTB
Jan 26 '16 #8
CD Tom
489 256MB
That's exactly what I was looking for. I'll look into the other options.
Thanks again for your help.
Jan 26 '16 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Nick Moore | last post by:
I have a C# forms app that accesses an Oracle database. When 'Release' built, it runs fine from the folder that it's built into but if I copy the app's .exe and .dlls to another folder it fails with...
5
by: Phil Stanton | last post by:
Can anyone let me have the code for opening the open file dialog box and getting either a file or folder name as the output. I suspect it will look like Function GetPathOrFile(InputPath as...
3
by: THY | last post by:
Hi, How do we set the web folder become application folder in order it can run asp.net web application ? I just complete my project and upload it to the server via ftp. But it can't run as the...
5
by: Dan | last post by:
I am working on a C# ASP.NET project where I need to allow the user to browse to a folder. The only way I see how to do this is use <input type=file>. But this makes the user select a file and...
3
by: VB Joshua | last post by:
How do I call a browse for folder dialog? Dim oBrowseFolder As New System.Windows.Forms.FolderBrowserDialog oBrowseFolder.ShowDialog() But I can not show a form modal for some reason?
6
by: ad | last post by:
I want to copy all files under a folder to another folder. If I use File.Copy(sourceFileName, destFileName, overwrite), it must specify all files name in the source and destionation. How can I...
4
by: rdemyan | last post by:
I'm using code from the following web page to open the API Browse Folder dialog http://www.mvps.org/access/api/api0002.htm It all works fine. But if the dialog box is open and the user closes...
0
by: =?Utf-8?B?TWlrZVo=?= | last post by:
VB.NET 2005 Release Folder and Debug Folder confuse me a lot. I used a application configuration file which locate in the same folder as EXE file. The config file is set by application. When I use...
1
by: =?Utf-8?B?d2lubGlu?= | last post by:
Hello 1)When using VS 2005 and VB.net when wouldn't the: reference folder, bin folder, obj folder not be present after creating a VB net Windows Application and only the form1.vb and MyProject...
5
by: madymsr | last post by:
Folder Option is not showing
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.