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 » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Need Mid Function



 
 
Thread Tools Display Modes
  #1  
Old May 13th, 2008, 10:53 PM posted to microsoft.public.access.queries
Dataman
external usenet poster
 
Posts: 1
Default Need Mid Function

I have a ClientSampID that looks like this: T2/LA-10-(0-6)

I am looking for a statement that will pull the text after the "/" and
before the first "-". Example: LA

There may be more than 2 characters after the "/" and before the first "-".
Example: T2/LAA-10-(0-6)

This statemant works if there are only 2 characters but fails if tthere are
mo

Left(Trim(Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,InStr(InStr(1,[ClientSampID],'-')+1,[ClientSampID],'-')-InStr(1,[ClientSampID],'-'))),InStr(1,Trim(Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,InStr(InStr(1,[ClientSampID],'-')+1,[ClientSampID],'-')-InStr(1,[ClientSampID],'-'))),'-')-1)Help would be appreciated.Thanks in advanceDC

  #2  
Old May 13th, 2008, 11:25 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Need Mid Function

Try this --
Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,
InStr([ClientSampID],'-')-InStr(1,[ClientSampID],'/')-1)

--
KARL DEWEY
Build a little - Test a little


"Dataman" wrote:

I have a ClientSampID that looks like this: T2/LA-10-(0-6)

I am looking for a statement that will pull the text after the "/" and
before the first "-". Example: LA

There may be more than 2 characters after the "/" and before the first "-".
Example: T2/LAA-10-(0-6)

This statemant works if there are only 2 characters but fails if tthere are
mo

Left(Trim(Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,InStr(InStr(1,[ClientSampID],'-')+1,[ClientSampID],'-')-InStr(1,[ClientSampID],'-'))),InStr(1,Trim(Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,InStr(InStr(1,[ClientSampID],'-')+1,[ClientSampID],'-')-InStr(1,[ClientSampID],'-'))),'-')-1)Help would be appreciated.Thanks in advanceDC


  #3  
Old May 13th, 2008, 11:46 PM posted to microsoft.public.access.queries
fredg
external usenet poster
 
Posts: 4,386
Default Need Mid Function

On Tue, 13 May 2008 15:53:36 -0600, Dataman wrote:

I have a ClientSampID that looks like this: T2/LA-10-(0-6)

I am looking for a statement that will pull the text after the "/" and
before the first "-". Example: LA

There may be more than 2 characters after the "/" and before the first "-".
Example: T2/LAA-10-(0-6)

This statemant works if there are only 2 characters but fails if tthere are
mo

Left(Trim(Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,InStr(InStr(1,[ClientSampID],'-')+1,[ClientSampID],'-')-InStr(1,[ClientSampID],'-'))),InStr(1,Trim(Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,InStr(InStr(1,[ClientSampID],'-')+1,[ClientSampID],'-')-InStr(1,[ClientSampID],'-'))),'-')-1)Help would be appreciated.Thanks in advanceDC


So you wish to get LA or LAA from your examples?

NewColumn:Mid([ClientSampID],InStr([ClientSampID],"/")+1,(InStr([ClientSampID],"-")-1)-InStr([ClientSampID],"/"))

The above expression should be all on one line.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 




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 05:19 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.