ACC2: Sample Function for a Directory-Selection Dialog BoxID: Q128886
|
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article demonstrates how to create a sample user-defined Access Basic
function that you can use to provide users with a directory-selection
dialog box. This method is similar to the Open file common dialog box that
can be called from Access Basic.
This sample function is based on the directory-selection function used by
the Microsoft Access Developer's Toolkit (ADT) Setup Wizard. It requires
that the SWU2016.DLL file be located in the Microsoft Access directory or,
if the sample function is used with a Microsoft Access run-time
application, that the SWU2016.DLL file be located in the same directory as
the MSARN200.EXE file.
You can ship the SWU2016.DLL file with a Microsoft Access application, but
it is only available when you install the ADT. It is copied to the Access
directory during ADT Setup. This file is not available from Microsoft Access
Product Support Services. Because this is a support file included with the ADT,
it is subject to change in future versions of the product.
This article assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools provided
with Microsoft Access. For more information about Access Basic, please
refer to the "Building Applications" manual.
To create a directory-selection dialog box on a form, follow the steps
below.
Declare Function zws_BrowseDir Lib "SWU2016.DLL" Alias "#2"_
(ByVal hwnd As Integer, ByVal szTitle As String, ByVal szDir_
As String) As Integer
Sub commdir_Click ()
On Error GoTo SelectDir_Err
Dim stDir As String
Dim iTmp As Integer
Dim stControl As String
stControl = "ChosenDir"
stDir = Trim$(IIf(IsNull(Me(stControl)), "", Me(stControl)))
stDir = stDir & Chr$(0) & Space$(255)
If zws_BrowseDir(Me.hwnd, "select directory", stDir) <> 0 Then
stDir = Left(stDir, InStr(stDir, Chr$(0)) - 1)
Me(stControl) = stDir
End If
Exit Sub
SelectDir_Err:
If Err = 53 Then 'File not found.
MsgBox "Could not load 'SWU2016.DLL', make sure file _
exists", 48
Else
MsgBox Error$ & Chr(13) & Chr(10) & " ErrorNum:" _
& Str(Err), 48
End If
Exit Sub
End Sub
Keywords : kbusage GnlOthr
Version : 2.0
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: April 9, 1999