Modify file name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am writing a procedure to import text files to tables in the database.
Tables in the db have neames like Routes, tblFirm, etc..

The export function I wrote appends the current table name to include the
UserName and an underscore to the front of the table name: i.e.
BobbyS_Routes, BobbyS_Firm, etc.

The user will have a list of txt files in a list box on the form. After
selecting the appropriate table it is assigned to a variable
(strTblName),modify the textfile name to not include the Username &
underscore.

Thank you
 
BobbyS said:
I am writing a procedure to import text files to tables in the
database. Tables in the db have neames like Routes, tblFirm, etc..

The export function I wrote appends the current table name to include
the UserName and an underscore to the front of the table name: i.e.
BobbyS_Routes, BobbyS_Firm, etc.

The user will have a list of txt files in a list box on the form.
After selecting the appropriate table it is assigned to a variable
(strTblName),modify the textfile name to not include the Username &
underscore.

Thank you

You don't explicitly ask a question, but I think you are asking how to
take a string, stored in strTblName, that is formatted like
"<username>_<tablename>", and drop the "<username>_" prefix. The
following line will do that:

strTblName = Mid(strTblName, 1 + InStr(strTblName, "_"))
 
Got it to work..thanks for the right direction tho..

strTblName = Mid(strTblName, InStr(strTblName, "_") + 1)
 
Odd, what I posted works for me, and I can't see any practical or
theoretical difference between

InStr(strTblName, "_") + 1

and

1 + InStr(strTblName, "_")
 
Back
Top