A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Extracting Text



 
 
Thread Tools Display Modes
  #1  
Old July 14th, 2009, 09:11 PM posted to microsoft.public.access.gettingstarted
Bre-x
external usenet poster
 
Posts: 103
Default Extracting Text

I have a table with one single text field.

S:\ENG\DATA\DWN\my file_1.pdf
S:\ENG\DATA\DWN\CUSTOMER\MSG\file.pdf
S:\ENG\DATA\DWN\CUSTOMER\My Subdir\my_other file.pdf

How do I extract the file name and the file path and save it on two text
fields?

the_path
S:\ENG\DATA\DWN
S:\ENG\DATA\DWN\CUSTOMER\MSG
S:\ENG\DATA\DWN\CUSTOMER\My Subdir

the_file
my file_1.pdf
file.pdf
my_other file.pdf

There are two constants: the file extension ".pdf" and the "S:\ENG\DATA\"

Thank you all

Bre-x


  #2  
Old July 14th, 2009, 10:10 PM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Extracting Text

On Tue, 14 Jul 2009 14:11:14 -0600, "Bre-x" wrote:

I have a table with one single text field.

S:\ENG\DATA\DWN\my file_1.pdf
S:\ENG\DATA\DWN\CUSTOMER\MSG\file.pdf
S:\ENG\DATA\DWN\CUSTOMER\My Subdir\my_other file.pdf

How do I extract the file name and the file path and save it on two text
fields?

the_path
S:\ENG\DATA\DWN
S:\ENG\DATA\DWN\CUSTOMER\MSG
S:\ENG\DATA\DWN\CUSTOMER\My Subdir

the_file
my file_1.pdf
file.pdf
my_other file.pdf

There are two constants: the file extension ".pdf" and the "S:\ENG\DATA\"

Thank you all

Bre-x


In A2002 (possibly 2003, I'm not certain) and later there's a function
InStrRev that will do this:

the_path: Left([fieldname], InStrRev([fieldname], "\") - 1)
the_file: Mid([fieldname], InStrRev([fieldname], "\") + 1)
--

John W. Vinson [MVP]
  #3  
Old July 14th, 2009, 10:15 PM posted to microsoft.public.access.gettingstarted
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Extracting Text

Path: Left([YourTextField], InStrRev([YourTextField], "/"))
File: RightLeft([YourTextField], (Len([YourTextField])+1)
-[InStrRev([YourTextField], "/"))

--
Build a little, test a little.


"Bre-x" wrote:

I have a table with one single text field.

S:\ENG\DATA\DWN\my file_1.pdf
S:\ENG\DATA\DWN\CUSTOMER\MSG\file.pdf
S:\ENG\DATA\DWN\CUSTOMER\My Subdir\my_other file.pdf

How do I extract the file name and the file path and save it on two text
fields?

the_path
S:\ENG\DATA\DWN
S:\ENG\DATA\DWN\CUSTOMER\MSG
S:\ENG\DATA\DWN\CUSTOMER\My Subdir

the_file
my file_1.pdf
file.pdf
my_other file.pdf

There are two constants: the file extension ".pdf" and the "S:\ENG\DATA\"

Thank you all

Bre-x



  #4  
Old July 15th, 2009, 12:35 AM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Extracting Text

On Tue, 14 Jul 2009 14:15:01 -0700, KARL DEWEY
wrote:

Path: Left([YourTextField], InStrRev([YourTextField], "/"))
File: RightLeft([YourTextField], (Len([YourTextField])+1)
-[InStrRev([YourTextField], "/"))


Karl, is RightLeft something you wrote or a typo? Shouldn't that be just:

Mid([YourTextField], InStrRev([YourTextField], "\") + 1)

Note that the Mid() function gets the rest of the string after the position in
the second argument if the third argument is absent, so you don't need to
subtract from the length of the field.
--

John W. Vinson [MVP]

  #5  
Old July 15th, 2009, 06:40 AM posted to microsoft.public.access.gettingstarted
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Extracting Text

Yes, I saw my typo after I read your first post.
--
Build a little, test a little.


"John W. Vinson" wrote:

On Tue, 14 Jul 2009 14:15:01 -0700, KARL DEWEY
wrote:

Path: Left([YourTextField], InStrRev([YourTextField], "/"))
File: RightLeft([YourTextField], (Len([YourTextField])+1)
-[InStrRev([YourTextField], "/"))


Karl, is RightLeft something you wrote or a typo? Shouldn't that be just:

Mid([YourTextField], InStrRev([YourTextField], "\") + 1)

Note that the Mid() function gets the rest of the string after the position in
the second argument if the third argument is absent, so you don't need to
subtract from the length of the field.
--

John W. Vinson [MVP]


  #6  
Old July 15th, 2009, 02:58 PM posted to microsoft.public.access.gettingstarted
Bre-x
external usenet poster
 
Posts: 103
Default Extracting Text

Thank you all!!




"Bre-x" wrote in message
...
I have a table with one single text field.

S:\ENG\DATA\DWN\my file_1.pdf
S:\ENG\DATA\DWN\CUSTOMER\MSG\file.pdf
S:\ENG\DATA\DWN\CUSTOMER\My Subdir\my_other file.pdf

How do I extract the file name and the file path and save it on two text
fields?

the_path
S:\ENG\DATA\DWN
S:\ENG\DATA\DWN\CUSTOMER\MSG
S:\ENG\DATA\DWN\CUSTOMER\My Subdir

the_file
my file_1.pdf
file.pdf
my_other file.pdf

There are two constants: the file extension ".pdf" and the "S:\ENG\DATA\"

Thank you all

Bre-x




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:43 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.