dbTalk Databases Forums  

Right([PartID],5) - help

comp.databases.ms-access comp.databases.ms-access


Discuss Right([PartID],5) - help in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ERIC
 
Posts: n/a

Default Right([PartID],5) - help - 07-28-2003 , 08:09 AM






I am trying to use the Right([PartID],5)command to pull the last 5
digits from a field, but I have some "PartID" that I need the last 6
or 7 characters. All the characters I need have "ZZZ" in front of
them. For example:

ZZZ00013
ZZZ000444
ZZZ0064185

Is there a way for access to get all the characters to the right of
"ZZZ", no matter how many characters?

Thanks for your help ,

Eric

Reply With Quote
  #2  
Old   
Bernard André
 
Posts: n/a

Default Re: Right([PartID],5) - help - 07-28-2003 , 08:24 AM






well, a quick and dirty way would be to work backwards...

let's assume your value is in a variable called tt

dim xs as integer, tpcar as string, resu as string

resu = ""

for xs = len(tt) to 1 step -1

tpcar = right(tt,xs,1)

if tpcar <> "Z" then

resu = tpcar & resu

else

exit for

end if

next xs



At the end of the loop, resu will contain the digits at the right of the
rightmost "Z"

should work,

Bernard

"ERIC" <DATAE2000 (AT) YAHOO (DOT) COM> wrote

Quote:
I am trying to use the Right([PartID],5)command to pull the last 5
digits from a field, but I have some "PartID" that I need the last 6
or 7 characters. All the characters I need have "ZZZ" in front of
them. For example:

ZZZ00013
ZZZ000444
ZZZ0064185

Is there a way for access to get all the characters to the right of
"ZZZ", no matter how many characters?

Thanks for your help ,

Eric



Reply With Quote
  #3  
Old   
Helmar Herman
 
Posts: n/a

Default Re: Right([PartID],5) - help - 07-28-2003 , 08:38 AM



If you know that the field will always start with the three characters
you want to ignore, then you could use:

MsgBox Mid$("ZZZ000444", 4)

Note that by omitting the 3rd parameter of the MID$ function, you are
selecting all characters starting with the 4th.

On 28 Jul 2003 06:09:37 -0700, DATAE2000 (AT) YAHOO (DOT) COM (ERIC) wrote:

Quote:
I am trying to use the Right([PartID],5)command to pull the last 5
digits from a field, but I have some "PartID" that I need the last 6
or 7 characters. All the characters I need have "ZZZ" in front of
them. For example:

ZZZ00013
ZZZ000444
ZZZ0064185

Is there a way for access to get all the characters to the right of
"ZZZ", no matter how many characters?

Thanks for your help ,

Eric


Reply With Quote
  #4  
Old   
Tom van Stiphout
 
Posts: n/a

Default Re: Right([PartID],5) - help - 07-28-2003 , 08:51 AM



On 28 Jul 2003 06:09:37 -0700, DATAE2000 (AT) YAHOO (DOT) COM (ERIC) wrote:

Try this:
Mid$([PartID], 4)

-Tom.


Quote:
I am trying to use the Right([PartID],5)command to pull the last 5
digits from a field, but I have some "PartID" that I need the last 6
or 7 characters. All the characters I need have "ZZZ" in front of
them. For example:

ZZZ00013
ZZZ000444
ZZZ0064185

Is there a way for access to get all the characters to the right of
"ZZZ", no matter how many characters?

Thanks for your help ,

Eric


Reply With Quote
  #5  
Old   
ERIC
 
Posts: n/a

Default Re: Right([PartID],5) - help - 07-29-2003 , 06:24 AM



Tom,
Thanks for your reply. I was going to use that command, but I will not
know if the char length will be 3-4 characters in front of the center.
Thanks!


Tom van Stiphout <tom7744 (AT) no (DOT) spam.cox.net> wrote

Quote:
On 28 Jul 2003 06:09:37 -0700, DATAE2000 (AT) YAHOO (DOT) COM (ERIC) wrote:

Try this:
Mid$([PartID], 4)

-Tom.


I am trying to use the Right([PartID],5)command to pull the last 5
digits from a field, but I have some "PartID" that I need the last 6
or 7 characters. All the characters I need have "ZZZ" in front of
them. For example:

ZZZ00013
ZZZ000444
ZZZ0064185

Is there a way for access to get all the characters to the right of
"ZZZ", no matter how many characters?

Thanks for your help ,

Eric

Reply With Quote
  #6  
Old   
Helmar Herman
 
Posts: n/a

Default Re: Right([PartID],5) - help - 07-29-2003 , 09:26 AM



The following code will search for the first occurance of a numeric in
the string, and will then return the numeric portion, thus allowing
for any number of characters before the numeric:

Dim iWork As Integer
Dim sWork as String
sWork = "ZZZ12345"

For iWork = 1 to Len(sWork)
if IsNumeric(Mid$(sWork, iWork, 1)) Then Exit For
Next

MsgBox "The numeric portion is: " & Mid$(sWork, iWork)




On 29 Jul 2003 04:24:38 -0700, DATAE2000 (AT) YAHOO (DOT) COM (ERIC) wrote:

Quote:
Tom,
Thanks for your reply. I was going to use that command, but I will not
know if the char length will be 3-4 characters in front of the center.
Thanks!


Tom van Stiphout <tom7744 (AT) no (DOT) spam.cox.net> wrote

On 28 Jul 2003 06:09:37 -0700, DATAE2000 (AT) YAHOO (DOT) COM (ERIC) wrote:

Try this:
Mid$([PartID], 4)

-Tom.


I am trying to use the Right([PartID],5)command to pull the last 5
digits from a field, but I have some "PartID" that I need the last 6
or 7 characters. All the characters I need have "ZZZ" in front of
them. For example:

ZZZ00013
ZZZ000444
ZZZ0064185

Is there a way for access to get all the characters to the right of
"ZZZ", no matter how many characters?

Thanks for your help ,

Eric


Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.