Better way to open a browse window linked to a folders on a server

BWG3

Registered User.
Local time
Today, 13:00
Joined
Sep 22, 2009
Messages
44
Happy New Year to all.

I have a form that contains a button that opens a folder browsing window which allows the user to select a specific folder on a server and it stores the folder path on the form which can be clicked on and opened for later use. I have it set so that the path when you first click on the button is linked to a folder path on another server. This is so the user does not have to click so many different file paths. My button opens up to the correct path and the user just has to select a single folder. My problem is that when I first open the database and go to enter data into a form, I click on the button and an error is displayed "Unable to browse the network...The request is not supported." It then defaults to the folder browsing window with all the available networks on it. Once I clicked the correct path to the folders I want, the button works just fine thereafter. It's like access does not know I have access to that network unless I show it I do.

My code is just...
spath = UnqualifyPath((path of server I want button to directly open up to))
Me.txtDir.value = BrowseForFolderByPath(spath)

BrowseForFolderByPath is a function located in a module. It is lengthy and I believe I got it from this site. If you would like to me to put it on just let me know.

Is there any code that can check the path to the server on an "on load" so that the error message doesn't come up anymore? Or is there a better a better way to bring up a specific directory and allow the user to select a folder to store on the form?

Thanks in advance for your help.
 
Hi

post a sample as I have a good browser code which I'll place in an post back. I just want to make sure that it fixes your error



Regs

nigel
 
Thanks for your help, Nigel. This is the module code that my form code is running off of.

Option Compare Database
Option Explicit

Private Type BROWSEINFO
hwndOwner As Long
pidlRoot As Long
sDisplayName As String
sTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Declare Function SHBrowseForFolder Lib "shell32.dll" (bBrowse As BROWSEINFO) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" (ByVal lItem As Long, ByVal sDir As String) As Long

' Let the user browse for a directory. Return the
' selected directory. Return an empty string if
' the user cancels.
Public Function BrowseForDirectory() As String
Dim browse_info As BROWSEINFO
Dim item As Long
Dim dir_name As String
'modified for MS Access/VBA
With browse_info
' .hwndOwner = Application.hWndAccessApp
.pidlRoot = 0
.sDisplayName = Space$(260)
.sTitle = "Select Directory"
.ulFlags = 1 ' Return directory name.
.lpfn = 0
.lParam = 0
.iImage = 0
End With
item = SHBrowseForFolder(browse_info)

If item Then
dir_name = Space$(260)
If SHGetPathFromIDList(item, dir_name) Then
BrowseForDirectory = Left(dir_name, _
InStr(dir_name, Chr$(0)) - 1)
Else
BrowseForDirectory = ""
End If
End If
End Function

Thanks again. Hopefully you can help me fix this error. :)
 

Users who are viewing this thread

Back
Top Bottom