Dec 7 2006, 11:56 AM
I have a button on my form that runs the BrowseforFolder module. This allows the user to access photos in a folder on their computer. I would like to disable two buttons on the mainform so the user can not click on them while having the browse for folder window open. I have succeeded on disabling the two buttons by calling a mouse down procedure, but have been unsuccessful on enabling the two buttons when either the user selects OK or CANCEL on the browse for folder window. I have tried the On Activate and On Got Focus procedures for the main form. Nothing seems to work. Any suggestions?
Dec 7 2006, 12:00 PM
what BrowseForFolder module do you mean?
Normally you would open up a dialog to browse through directories and these dialogs are normally modal meaning that nothing else can be selected/touched until either OK or CANCEL was pressed.
Dec 7 2006, 12:44 PM
Option Compare Database
'************** Code Start **************
'This code was originally written by Terry Kreft.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'Code courtesy of
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
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) _
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
Dim szRetPath As String
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYFSDIRS
dwIList = SHBrowseForFolder(BI)
szPath = Space$(512)
X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
If X Then
wPos = InStr(szPath, Chr(0))
szRetPath = VBA.Left$(szPath, wPos - 1)
szRetPath = ""
BrowseFolder = szRetPath
'*********** Code End *****************
Dec 7 2006, 12:50 PM
Have you tried clicking anything while the dialog is open? As mentioned it is modal and won't allow anything to be clicked until it is closed. Also keep in mind that this will only return the directory path and not any file information from within the directories.
Dec 7 2006, 12:53 PM
I am able to click on the main form and move it around. I can even close the main form and the browse for folder window is still open.
Dec 7 2006, 12:55 PM
You most likely have the pop up property of this form set then. Either change that or just set the visible property of the form to false before you open the browse dialog.
Dec 7 2006, 01:02 PM
The form is not set as a pop up, but I will try setting the visible property to false. How would I set the visible property back to true though?
Dec 7 2006, 01:05 PM
One other thing I noticed when opening the browse for folder window is that it shows up in my task bar at the bottom of the screen.
Dec 7 2006, 01:47 PM
are you sure it is not set to pop up? Open the form's property dialog...go to the other tab...and make sure pop up is set to NO. The form should NOT be available for selection if the browse dialog appears.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here