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

Control to get the path of a file 1

Status
Not open for further replies.

easycode

Programmer
Jan 28, 2005
195
US
i am trying to place a control in a form to capture the path of a file. Can anyone tell what is the name of the control. The result would be a window with a tree directory wher the user can select any folder and subfolder until user get the folder wanted, and then assign that path to a string.
i appreciate your help. Thanks

 
ma2k,

In 2000, you can use the Microsoft CommonDialog1 combined with a button control.

You add the CommonDialog1 control to your form and then reference it in your code via a button OnClick event.

Note: the CommonDialog1 control is only there to be referenced, when you runtime the form, it disappears.

Also, disregard the public call to LinkTables.

Here is a sample of one, short and sweet:


Private Sub cmdFindDB_Click()
'OnClick event for a button control
'Refences a CommonDialog1 control, named CommonDialog1

Dim intTrimLen As Integer
Dim intFullLen As Integer
Dim strPath As String
Dim strDB As String

CommonDialog1.InitDir = "\"
CommonDialog1.Filter = "Millennium Client Database (*.mdb)|*.mdb|All Files (*.*)|*.*"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
intTrimLen = Len(CommonDialog1.FileTitle)
intFullLen = Len(CommonDialog1.FileName)
strPath = Left(CommonDialog1.FileName, intFullLen - intTrimLen)
Me!DatabasePath.SetFocus

Me!DatabasePath.Text = CommonDialog1.FileName
strDB = CommonDialog1.FileName

Else: Exit Sub
End If

LinkTables (strDB)

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top