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!

Oen browsing window to get file path

Status
Not open for further replies.

EvilCabal

Programmer
Jul 11, 2002
206
CA
Hi all, I have an option in my database that allow to user to set the path for some files used through the application. My problem is that the user has to manually type in the whole path. Is there a way I could open a browsing window so the user could select the directory in witch the files are instead of typing it in? Thanx a lot.
 
Try looking into the help files on Common Dialog Box. I believe this may point you to a possible solution.

Marrow
 
The easiest way is to use the ActiveX Common Dialogue control--you'll find it by clicking the "More controls" part of the contol toolbar (there's an API method wrapped into it) or if you like API's you can do it directly (there have been some posts with this code).

Here's the code from a form that I used to import from an Excel file of the user's choice (it should be obvious what needs to be changed for your context):
[tt]

Private Sub Form_Load()
On Error Resume Next

CDLG.Filter = "Excel Files (.xls) |*.xls"

txtFile = "No file selected"

Private Sub CDLG_Updated(Code As Integer)

m_strExcelFile = CDLG.FileName


MsgBox m_strExcelFile


End Sub

Private Sub cmdGetFile_Click()
CDLG.ShowOpen

txtFile = CDLG.FileName

End Sub


End Sub[/tt] Jeff Roberts
Analysis, Design, & Implementation
RenaissanceData.com
 
Thanx for the help Quehay but I can't find the ActiveX common dialog control. I'm using access 2000, does it need a particular reference or something else that I'm might not be aware of?
 
On the control toolbar click at lower right where the ellipsis is (...). Then you'll see "COMMON DIALOG CONTROL" listed as one of the other controls. Jeff Roberts
Analysis, Design, & Implementation
RenaissanceData.com
 
No, as I said before, it's not there... Any ideas why?
 
You got me...there's no particular code reference that I've got checked. At worst you can use the API call directly. Jeff Roberts
Analysis, Design, & Implementation
RenaissanceData.com
 
Never used API before, any exemple or good link to get me started pleaz. Thanx again!
 
See thread181-307043 in Acces--Other. Someone just posted Ken Getz's code for Common Dialogue. You declare an API, insert the code, and then call it like any other sub/function. Jeff Roberts
Analysis, Design, & Implementation
RenaissanceData.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top