UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Save Folder Location, Access 2003    
 
   
jarotoouk
post Apr 10 2013, 02:10 PM
Post#1



Posts: 169
Joined: 9-May 05
From: UK


HI folks, I'm back again!!
This time I'm trying to find a way to store the location of a folder so that my user can quickly located associated files.
The db is basically used by a property management firm to manage repairs etc to different properties.
Each property has a folder on the company server, including engineer reports, site diagrams etc.
Odon't want to store each document in the db individually since documents can be added at ant time by any user, so I want the db operator to select the 'site folder', which will be stored in a memo field, and hopefully can be used as a hyperlink type idea to open the folder from another form later on.
I have some code I was using which allows me to select specific files and store the addresses in a list box, but nothing to let me choose an entire folder. This code was taken from the MS website as my own was very bulky.
CODE
Private Sub cmdFileDialog_Click()
' This requires a reference to the Microsoft Office 11.0 or 12.0 Object Library.
   Dim fDialog As Office.FileDialog
   Dim varFile As Variant
   ' Clear the list box contents.
   Me.FileList.RowSource = ""
   ' Set up the File dialog box.
   Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
   With fDialog
      ' Allow the user to make multiple selections in the dialog box.
      .AllowMultiSelect = True
            
      ' Set the title of the dialog box.
      .Title = "Select One or More Files"
      ' Clear out the current filters, and then add your own.
      .Filters.Clear
      .Filters.Add "Word Documents", "*.DOC"
      .Filters.Add "PDF Documents", "*.PDF"
      .Filters.Add "All Files", "*.*"
      ' Show the dialog box. If the .Show method returns True, the
      ' user picked at least one file. If the .Show method returns
      ' False, the user clicked Cancel.
      If .Show = True Then
         ' Loop through each file that is selected and then add it to the list box.
         For Each varFile In .SelectedItems
            Me.FileList.AddItem varFile
         Next
      Else
         MsgBox "You clicked Cancel in the file dialog box."
      End If
   End With
End Sub

I did download this demo from another site http://bytes.com/topic/access/insights/916...ledialog-object.
It works when I run it as a stand-alone db, but when I import the components into my own db, it stops working for some odd reason!!
Go to the top of the page
 
doctor9
post Apr 10 2013, 02:34 PM
Post#2


Remembered
Posts: 18,324
Joined: 29-March 05
From: Wisconsin


jarotoouk,
You can use this method from The Access Web to allow the user to select a folder using a Windows browser dialog box.
Based on this statement, you probably just need a text field in your table where you are storing the properties.
Hope this helps,
Dennis
Go to the top of the page
 
theDBguy
post Apr 10 2013, 02:39 PM
Post#3


Access Wiki and Forums Moderator
Posts: 76,375
Joined: 19-June 07
From: SunnySandyEggo


Hi,
You could also try something like:
CODE
Private Sub cmdBrowse_Click()
Dim fDialog As Object
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
    If .Show Then Me.FolderNameField = .SelectedItems(1)
End With
Set fDialog = Nothing
End Sub

(untested)
Just my 2 cents... 2cents.gif
Go to the top of the page
 
jarotoouk
post Apr 13 2013, 05:22 AM
Post#4



Posts: 169
Joined: 9-May 05
From: UK


Thanks guys. I'll give them a go.
pdate: Second method works really well, so I'll go with that.
T
Go to the top of the page
 
theDBguy
post Apr 14 2013, 12:08 PM
Post#5


Access Wiki and Forums Moderator
Posts: 76,375
Joined: 19-June 07
From: SunnySandyEggo


Hi,
Dennis and I were happy to assist. Good luck with your project.
Go to the top of the page
 
tjgillis02
post Sep 7 2019, 03:04 PM
Post#6



Posts: 87
Joined: 19-August 06
From: San Diego, CA


I did not find the second code to work (but I may have done something wrong).

I found the first recommendation for the code from The Access Web, by Terry Kreft, to work very nicely. thumbup.gif

Thanks to all!
This post has been edited by tjgillis02: Sep 7 2019, 03:06 PM
Go to the top of the page
 
theDBguy
post Sep 7 2019, 05:44 PM
Post#7


Access Wiki and Forums Moderator
Posts: 76,375
Joined: 19-June 07
From: SunnySandyEggo


Hi. Glad to hear you got it working. You didn’t mention how the second code didn’t work; but just for fun, could you try changing one line to this?
CODE
Set fDialog = Application.FileDialog(4)

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    14th October 2019 - 03:07 AM