Question : Using File Dialog to select directory

I have a table that opens up only the first time the user opens the database.  At this time, I would like for them to select the rootdirectory for the whole project.  I would like to use the file selector dialog, but I only want folders to show up... is there a folder selector dialog?

Once they select the root directory, I would like to go ahead and create all of the folders that will be used by the database.  Right now I have a hard coded

global const ProjectDirectoy = "\\servername\\folder\"  

But I would like to create a global variable and set it by the folder dialog and then create all of the necessary folders inside of the folder.

Any suggestions?

I need to create:
ProjectDirectoy\MEL\
ProjectDirectory\MEL\CMEL
ProjectDirectory\MEL\DMEL
ProjectDirectory\PDFReports\
ProjectDirectory\PDFReports\ATR
ProjectDirectory\PDFReports\IIF
ProjectDirectory\PDFReports\RIF
ProjectDirectory\PDFReports\Startup
ProjectDirectory\PDFReports\ATP
ProjectDirectory\PDFReports\FAT
ProjectDirectory\PDFReports\ConstructionDwgs

That is all.

Answer : Using File Dialog to select directory

To get the Project Directory or name you can use:
Application.CurrentProject.Path
Application.CurrentProject.FullName
Application.CurrentProject.Name

For the file dialog for only folders use:

You can call the window's file dialog from Access.  The Windows's file dialog is the window that almost all programs use to open or save a file. To see the file dialog, goto File, Open in Access.
Calling the window's file dialog from Access requires a reference set to Microsoft Office x.xx Object Library (Visual Basic Editor, Tools, References).

Simple File Dialog call:

Dim strPathFileName As String

'In the "With Application.FileDialog" line, you can use:
'   msoFileDialogFilePicker, msoFileDialogFolderPicker, msoFileDialogOpen or msoFileDialogSaveAs
With Application.FileDialog(msoFileDialogFolderPicker)
    .Title = "Select folder"
    .AllowMultiSelect = False
    .Filters.Clear
    .Filters.Add "All", "*.*", 2
    .InitialFileName = "C:\"
    If .Show Then
        strPathFileName = .SelectedItems(1)
    Else
        MsgBox "No folder selected!"
    End If
End With
Random Solutions  
 
programming4us programming4us