How do I trim the file name?

  • Thread starter Niklas Östergren
  • Start date
N

Niklas Östergren

Hi!

The user can save file path to a file in a table in my application, like
this:

C:\Documents and Settings\ImportText.txt

I´m using code written by Ken Getz and Paul Ltwin to open the dilaoge box
"Open/Save files. I have figure out how to save the path into my table,
using this code (see below).

But how do I either trim the path OR get the file name?

I´d like to store not only the path but also the filename in a seperat
field.

TIA!
// Niklas

'=========================================
Dim rec As DAO.Recordset
Dim strFilePath As String
Dim strFilter As String
Dim lngFlags As Long

strFilter = ahtAddFilterItem(strFilter, "Excell Files (*.xls)", "*.XLS")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
strFilter = ahtAddFilterItem(strFilter, "Word Files (*.doc)", "*.DOC")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

strFilePath = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Välj fil att länka till...")

If Not strFilePath & "" = "" Then

Set rec = Currentdb().OpenRecordset("tblDocument", dbOpenDynaset)

With rec
.AddNew
!DocumentPath = strFilePath
.Update
End With

' Clean up
rec.Close
Set rec = Nothing
End If
'=========================================================
 
R

Rick Brandt

Niklas Östergren said:
Hi!

The user can save file path to a file in a table in my application, like
this:

C:\Documents and Settings\ImportText.txt

I´m using code written by Ken Getz and Paul Ltwin to open the dilaoge box
"Open/Save files. I have figure out how to save the path into my table,
using this code (see below).

But how do I either trim the path OR get the file name?

I´d like to store not only the path but also the filename in a seperat
field.

If the file will always exist you can just use Dir("FullPath") to get the
file name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top