Query to strip file name from path?

  • Thread starter Thread starter Kahuna
  • Start date Start date
K

Kahuna

Any one got a clue how to strip the filename off a path using a query (I
have an entire table of file links that need the path changed) preferably
without using a function?
 
I know you didn't want a function, but this is the only
way I could figure it out. You're welcome to try this or
not as you see fit.

Public Function isolate_File(strPath As String) As String
Dim intSearch As Integer
Dim strLeft As String
Dim i As Integer
Dim intAgain As Integer

Do
i = intSearch + 1
intSearch = InStr(i, strPath, "\")
strLeft = Mid(strPath, intSearch + 1)
intAgain = InStr(strLeft, "\")
Loop Until intAgain = 0

isolate_File = strLeft

End Function
 
Use the function that Jim Kennedy's wrote. Place this in a public module.
Make sure you put the function as a PUBLIC FUNCTION.

In your query, call the function like this:

Select Field1, Field2, Field3, isolate_File( FieldX ) as FieldX, ...
From ....
Where ....

HTH

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
Thanks guys, that's the format I have currently but was hoping there was a
faster method.

Cheers
 
See where you're heading Rob but the file links are pointing at many
different locations. I have some pointing at documents such as procedures,
some at graphics and others at SAP files etc. Each user could have their own
store of file links or directories.

The aim is to allow the user to easily change the directory path in the link
should they say... have to move all their files to a new server or directory
structure.

Cheers
 
Thanks Rob - that's how I structure my 'back-end' connections listing, but
in this case the file links table didn't appear as if they would get so
complex - and they are in 3 back-ends out in the real world now. Hence I
need code rather than a re-structure.

Cheers
 
Back
Top