Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveX tree-view a possibility? 2

Status
Not open for further replies.

NICKTHEGREEK

Programmer
Sep 12, 2001
11
GB
I am currently creating a project management database which will be stored on a shared drive. Each project that will be logged on the database will have it's own folder on the shared drive where any documents/spreadsheets etc related to that project will be stored. I have created a field in my projects database that specifies the exact location of the project folder on the database. I have the field set-up as a hyperlink field so the folder can be accessed by simply clicking the field. The problem is you have to type the path of the folder exactly how it is, which is sometimes very long, which makes errors a common occurrance. The path is also important because invoices etc are exported to the folder specified. Is it possible to create a pop-up box so the folder can be selected from a windows explorer-type view (and the path entered into a field as a text string) a rather than manually typed in? Also, can I use a function that will create folders? If anyone can help please I'd be very grateful.

Thanks in advance

Nick
 
Try this from a module:
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long

Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _
As Long

Private Const BIF_RETURNONLYFSDIRS = &H1
Public Function BrowseFolder(szDialogTitle As String) As String
Dim x As Long, bi As BROWSEINFO, dwIList As Long
Dim szPath As String, wPos As Integer

With bi
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYFSDIRS
End With

dwIList = SHBrowseForFolder(bi)
szPath = Space$(512)
x = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)

If x Then
wPos = InStr(szPath, Chr(0))
BrowseFolder = Left$(szPath, wPos - 1)
Else
BrowseFolder = ""
End If
End Function

I call "BrowsFolder" by double clicking on a text field:
Me![DirPath] = BrowseFolder("Select Folder where filesare located")

HTH

Rich O
 
wow! thank you so much Rich, you've saved me a LOT of file relocating!

Nick
 
Public Sub CreateFolder(Foldername)

MkDir Foldername

End Sub

Of course you would want to first verify that you were at the correct location. If you send a foldername only it would create the folder in the CurDir. If you send a full path it would create it there.

Steve King Growth follows a healthy professional curiosity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top