GOCHESTER.COM
Search:
 
 
Membership
 
  Member Login
Become a Member
Reset Password
 
     

 
Site Links
 
  Index
News Articles
View Articles By Category
 
     

 
Access String Functions
Category: Database related articles
By: Chester Zhang - May 27th, 2009
This article has been read: 80 times.

Request: Convert String "10000110101345" into currency format like "$100001101013.45".

Solution:
SELECT "$"+ Left( "10000110101345", InStr( "10000110101345",Right( "10000110101345",2))-1)+"."+Right( "10000110101345",2) as Dollar, InStr( "10000110101345",Right( "10000110101345",2)) as pos, Right( "10000110101345",2) as Desimal, "10000110101345" as textTot;





Now let us summarize the String functions in the MS Access.

  1. Len(string)

    Len(string) returns the number of characters in the string. You can specifiy the string itself in quotation marks, or you can speciy the field that contains the text string.


    Sample: Len("Northwind") returns 9




  2. Left(string, length)

    Left(string,length) returns a specified number of characters from the left side of a string.


    Sample: Left("Northwind",5) returns "North"




  3. Right(string, length)

    Right(string, length) returns a specified number of characters from the right side of a string


    Sample: Right("Northwind",4) returns "wind"




  4. InStr ([start],string1, string2 [, compare])

    InStr([start,] string1, string2[, compare]) returns a number specifying the position of the first occurrence of one string within another.




    1. start is optional, and it is a number that specifies the position of the character where you want to begin searching. For example, if start is 3, the search begins at the third letter in the string.

    2. string1 is the string, or the field containing the string that you are searching in.


    3. string2 is the string, or the field containing the string, that you are searching for.


    4. compare is optional, and it determines how the InStr function compares string1 and string2. The default comparison type is binary and therefore case-sensitive.



    Samples:


    1. InStr(1, "Northwind", "r") returns 3

    2. InStr("Northwind", "r") returns 3

    3. InStr("Northwind", "x") returns 0

    4. InStr("Northwind", "wind") returns 6

    5. InStr("Chester Zhang", "") returns 8











Reference site: FontStuff - ACCESS TIPS

<><


Back to News Articles
View Articles From Database related articles Category