Results 1 to 5 of 5
  1. #1
    grapin is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    5

    Access 2010 and HyperLink to Folder

    I have a form that allows the user to select a filename as a hyperlink, which the forum helped me with a couple weeks ago.



    Now, I need to allow the user to browse to a folder and then make that folder path a hyperlink on the form. I also need to set the default directory for the user to start browsing in.

    I have found other information about SHGetPathFromIDListA (windows api), but have yet to get it to work.

    Any suggestions?

    Thanks in advance,

  2. #2
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Check out the FileDialog object type in MS Access (it was new in A2003 - it should still be in A2010) - it does everything you want to do, by using the built-in Windows file open / file save dialog. You can have it select files or folders; here is how I use it to select a folder:

    Function Change_File_Location(Current_Location As Variant, Dialog_Title As String) As Variant
    Dim CurrentProcedure As String
    On Error GoTo ErrProc
    CurrentProcedure = "Change_File_Location"
    Dim fd As FileDialog
    Dim ReturnPath As Variant, ReturnValue As Integer
    Set fd = Application.FileDialog(msoFileDialogFolderPicker)
    '
    ' Initialize the directory with the current value
    '
    If IsNull(Current_Location) Then
    fd.InitialFileName = "C:\"
    Else
    fd.InitialFileName = Current_Location
    End If
    fd.title = "Select a folder for " & Dialog_Title
    ReturnValue = fd.Show
    If ReturnValue <> 0 Then
    '
    ' Dialog was not closed with "Cancel"
    '
    Change_File_Location = fd.SelectedItems(1)
    Else
    '
    ' Return value is the same as the initial value
    '
    Change_File_Location = Current_Location
    End If
    Set fd = Nothing

    Exit Function
    ErrProc:
    Process_Error CurrentForm, CurrentProcedure, Err.Description
    End Function


    Process_Error is one of my own procedures.

    HTH

    John

  3. #3
    grapin is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    5
    Thank you so much for your quick response. I appreciate it.

    I was basically doing the same as your email to select a particular file. However, this time around, I need just the folder. The filedialog box forces the user to select a file from the folder.

    So, the Change_File_Location = fd.SelectedItems(1) returns the folder and a file. Is there a way to just select the folder and bring back the folder path and store it in the hyperlink field.

    Just wondering .... your way, I will need to parse the filename off from the folder path.

  4. #4
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Yes, the msoFileDialogFolderPicker in Set fd = Application.FileDialog(msoFileDialogFolderPicker) is the setting used to return a folder. To select a file, use msoFileDialogFilePicker.

    John

  5. #5
    grapin is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    5

    Access 2010 and form hyperlink

    Quote Originally Posted by John_G View Post
    Hi -

    Yes, the msoFileDialogFolderPicker in Set fd = Application.FileDialog(msoFileDialogFolderPicker) is the setting used to return a folder. To select a file, use msoFileDialogFilePicker.

    John
    Hi, John:

    Thanks so much for your last reply. Since I am late binding, I could not select not find the msoFileDialogFolderPicker parameter, nor did I know it's value is 4. But, I have worked around that now and it's working.

    Thanks again for all your help and quick responses,

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access 2010 and form hyperlink
    By grapin in forum Programming
    Replies: 2
    Last Post: 03-22-2012, 01:11 PM
  2. open folder/Make new folder(example)-VBA Code
    By Madmax in forum Code Repository
    Replies: 3
    Last Post: 03-13-2012, 09:17 AM
  3. Replies: 9
    Last Post: 10-13-2011, 01:30 PM
  4. Access database in stored in temp folder ?
    By Raju Sheth in forum Access
    Replies: 3
    Last Post: 02-05-2011, 02:37 AM
  5. Enter a folder name and open that folder
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 09-05-2010, 04:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums