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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VB code for "Browse folder" in access 2k/97

Status
Not open for further replies.

Taha60

Technical User
Jun 21, 2002
54
CA
Hello everyone... :)

I found very good code that would I would like to include into my access app. at
Can anyone sugggest as to how I can encorporate that code into my access appilcation.

I was thinking of making it an ACTIVEX then inserting the activeX into my access 2k/97 since I dont know if that raw code (i think it was made for vb6) will work in access 97/2k...

I am open to lots of suggestions...

Thanks Taha
thamiral@uwo.ca
 
If found this code to work in my apps:

Function pickFolder() As String
Dim shellapplication As Object
Dim folder As Object
Dim optns As Integer

Set shellapplication = CreateObject("Shell.Application")

If Instructions = "" Then Instructions = "Pick your Folder"
optns = IIf(ShowEditBox, 17, 1)
Set folder = shellapplication.BrowseForFolder(hWndAccessApp, Instructions, optns)
If folder Is Nothing Then
pickFolder = ""
Else
pickFolder = folder.Self.Path
End If

Set shellapplication = Nothing
Set folder = Nothing
End Function
 
Hello waldemar...

Can you please tell me how you implemented that ... i.e ... a sample db would do excellent ... my email is thamiral@uwo.ca...

Thanks .... I sure do hope this one works in access versions 2k/97/xp Taha
thamiral@uwo.ca
 
Hello....

I tried the code above just as a normal func. which I invoked when a button was pressed and I got "error code:429 ActiveX cant create object"

Can you help .. i was using access 2k

thanks Taha
thamiral@uwo.ca
 
Hello again ....

I just tried it in access 97 and got Abmigious name detected in Command0_Click...


A sample database would really help especially now...

thanks...

Taha
thamiral@uwo.ca
 
Hmm :( Works fine with my access 2k. Just paste in a module and call strFolder=pickFolder() from anywhere
 
Hello..

Thanks for the help... I found out how to do it anyway.,,,

thanks Taha
thamiral@uwo.ca
 
What is solution. I'm curious, since I'm not very familiar with all that Late Binding stuff...
 
Yello...

What is late binding??? :) :)

Zis is vhat I did. Me hope zis zatizfies ur curiosity ;)

Option Compare Database
Option Explicit

Private Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const MAX_PATH = 260

Private Declare Function SHBrowseForFolder Lib _
"shell32" (lpbi As BrowseInfo) As Long

Private Declare Function SHGetPathFromIDList Lib _
"shell32" (ByVal pidList As Long, ByVal lpBuffer _
As String) As Long

Private Declare Function lstrcat Lib "kernel32" _
Alias "lstrcatA" (ByVal lpString1 As String, ByVal _
lpString2 As String) As Long

Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type


Private Sub Command1_Click()
'Opens a Browse Folders Dialog Box that displays the
'directories in your computer
Dim lpIDList As Long 'Declare Varibles
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo

szTitle = "Hello World. Click on a directory and " & _
"it's path will be displayed in a message box"
'Text to appear in the the gray area under the title bar
'telling you what to do

With tBrowseInfo
.hWndOwner = Me.Hwnd 'Owner Form
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
End With

lpIDList = SHBrowseForFolder(tBrowseInfo)

If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
MsgBox sBuffer
End If

End Sub


Taha
thamiral@uwo.ca
 
Hello ..

I would really like to apologize for the multi post ...

I am new to this area and double clicked once too many times on the submit post button in order to avoid the "preview postpage from loading ... ( I am used to clicking preview post )

Thanks Taha
thamiral@uwo.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top