dbTalk Databases Forums  

Select left

comp.database.ms-access comp.database.ms-access


Discuss Select left in the comp.database.ms-access forum.



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

Default Select left - 11-25-2003 , 01:06 PM






I am trying to select data from the left of a delimiter. I have a
part number like ABCD123-TOP all of the part numbers are like this. I
want to select the data to the left of the -. The kicker is the data
to the left of the - is not of a standard length. It might be 5
characters or 20 but whatever it is I want it. Any ideas?

Reply With Quote
  #2  
Old   
Scott McDaniel
 
Posts: n/a

Default Re: Select left - 11-25-2003 , 07:17 PM






Function GetFirstPart(YourString As String) As String
Dim nPos As Long

nPos = InStr(YourString, "-")
GetFirstPart = Left(YourString, nPos)
End Function

You call this function like this:

Dim strFirstPart

strFirstPart = GetFirstPart("ABCD123-TOP")

and strFirstPart would then contain "ABCD123" ...

--
Scott McDaniel
CS Computer Software
www.thedatabaseplace.net

"ANDY PHILLEY" <APHILLEY (AT) WATSONFURNITURE (DOT) COM> wrote

Quote:
I am trying to select data from the left of a delimiter. I have a
part number like ABCD123-TOP all of the part numbers are like this. I
want to select the data to the left of the -. The kicker is the data
to the left of the - is not of a standard length. It might be 5
characters or 20 but whatever it is I want it. Any ideas?



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.