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

Extract Path Info from Browse File Function

Status
Not open for further replies.

CMPaccess

Technical User
Dec 18, 2003
52
AU
I know this seems to be a common theme but as I'm new to prgramming I'm having trouble understanding how I can do this.

I have a code:-

Private Sub Command62_Click()
Dim strFileFolderName As String
Dim cmdlgOpenFile As New clsCommonDialog
Const clngFilterIndexAll = 5

cmdlgOpenFile.Filter = "Database Files (MDB)|*.mdb|" & _
"Text Files (TXT)|*.txt|PDF Files (PDF)|*.pdf|" & _
"HTML Files (HTM,HTML)|*.htm*|All Files (*.*)|*.*"

' Set the default file type selection to "All"
' (the fifth item in the above list)
cmdlgOpenFile.ShowOpen
strFileFolderName = cmdlgOpenFile.FileTitle
Me.CADFilename = strFileFolderName
DoCmd.OpenForm "Drawings Register"
CADFilename.SetFocus
SendKeys "{F2}", True
SendKeys "{backspace 4}", True


End Sub


This lets you browse to a file name and returns that info to a field.

what I would like to do is to strip the path data into another field.

Is this possible ??

thks
 
Some of the string manipulation functions spring to mind. In Access 2000+ versions, the InStrRev function would search from the end of a string and return the position of a given string within the string, then use for instance the Mid function on it?

[tt]msgbox mid$(strFileFolderName,instrrev(strFileFolderName ,"\")+1)
msgbox mid$(strFileFolderName,1,instrrev(strFileFolderName ,"\"))[/tt]

Roy-Vidar
 
Roy,

I tried the above but that will only return the Filename.

What I missed out is the CLsCommonDialog part of the code.

If use

strFileName = cmdlgOpenFile.FileName

that returns the whole string. (i.e. path and filename)

C:\Test\drawing.dwg

Is there a way to strip that so that it only returns the path eg

C:\Test\

thanks


 
he he - it seems my first suggestion addresses your last question, not the first, I totally misunderstood your first question [blush]

Roy-Vidar
 
Have you tried this ?
Left(cmdlgOpenFile.FileName, InStrRev(cmdlgOpenFile.FileName, "\"))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PH,

I had actually tried using the Left Command function, well I thought in the same way you show.

Anyway tried again and it works perfectly.

Thanks again !!!

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top