Logo
 
Miscellaneous

String

# OBJECTIVE PROG CODE NOTES
1
Combine cells into one cell
EXCEL

Solution: CONCATENATE function
In the results cell, type:
=CONCATENATE(A1,"-",B1)

In this example, if cell A1 was "123" and cell B1 was "456," the result would be "123-456."
2
Combine fields into one field
ACCESS
In a created query field, type:
New Field: [FName] & " " & [LName]
In this example, if the [FName] was "Ralph" and [LName] was "Jones," the result in [New Field] would be "Ralph Jones."
3
Convert string of numbers (text format) to number format (Integer)
ACCESS
CInt Function
This is used for numbers up to 33,767 (Integer)
4
Convert string of numbers (text format) to number format (Integer)
ACCESS
CLng Function
This is used for numbers up to 2,147,483,647 (Long Integer)
5
Convert string of numbers (text format) to number format (Integer)
ACCESS
VAL Function
Returns a variant. It can take a bit longer due to this. If the string contains a character, it stops.
6
Convert string of numbers (text format) to currency format
ACCESS
CCur Function
Returns a currency. This will allow values up to approximately 922 trillions dollars.
7
Isolate certain digits in a fixed string of numbers (our example will be a 10-digit number).
EXCEL
In the results cell, type:
=MID(A1,4,3)
"A1" is the cell containing the string. "4" represents the digit location. "3" represnts how many digits you want from the "4". In our example, if "A1" was 7351254784, it would return "125".
8
Isolate certain digits in a fixed string of numbers (our example will be a 10-digit number)
BUSINESS
OBJECTS
Formula Definition Box:
=Substr ( [FieldName] ; 4 ; 3 )
"4" represents the digit location. "3" represnts how many digits you want from the "4". In our example, if the string is 7351254784, it would return "125".
9
Isolate certain digits in a fixed string of numbers (our example will be a 10-digit number)
ACCESS
In a created query field, type:
ABC:MID([FieldName],4,3)
10
Counts then number of characters in a string.
EXCEL
In the results cell, type:
=LEN(A1)
11
Returns the first (left) three characters of a string.
ACCESS
In a created query field, type:
X:Left([Y]![Z],3)
Or another method could be the following:
X:Left([FieldName],3)
"X" is the name of our new field. "Y" is the name of the table. "Z" is the name of the field with the string. "3" is used because we want to return the first three (3) digits. Note: The "[Y]!" reference might be optional, depending on the complexity of the query.
12
Returns the first (left) three characters of a string.
EXCEL
In the results cell, type:
=LEFT(A1,3)
"A1" is the cell containing the string. You want the first three digits, so this is where the "3" comes from. In our example, if "A1" was 7351254784, it would return "735".
13
Returns the last (right) three characters of a string.
ACCESS
In a created query field, type:
X:Right([FieldName],3)
14
Returns the last (right) three characters of a string.
EXCEL
In the results cell, type:
=RIGHT(A1,3)
"A1" is the cell containing thestring. You want the last three digits, so this is where the "3" comes from. In our example, if "A1" was 7351254784, it would return "784".
15
Create a wildcard parameter query
ACCESS
In the "criteria" of a query, type:
Like"*"&[FieldName]&"*"
16
Take a string, and capitalize the first letter in each word.
ACCESS
In a created query field, type:
NewField:StrConv([FieldName],3)
17
Converting Names to Regular Names with Upper Case in first Character Only.
ACCESS
FirstCharacter = Left(Me.txtLastName, 1)
FirstCharacterCap = UCase(FirstCharacter)
HowLong = Len(Me.txtLastName)
Lastcharacters = LCase(Right(Me.txtLastName, HowLong - 1))
MoveLastName = FirstCharacterCap & Lastcharacters
18
Take string, and pulls only the first word.
ACCESS
In a created query field, type:
x:
IIf(InStr([FieldName]," ")>0,Left([FieldName],InStr([FieldName]," ")-1),[FieldName])
19
Remove the dashes, parenthesis, slashes, etc., from a text field.
ACCESS
In a created query field, type:
X: Replace(Replace(Replace(Replace([YourField],"-",""),"/",""),chr(39),"")," ","")
20
Parse a [FullNm] field to [Last Name],[First Name]
ACCESS

In a created query field, type:
X:Mid([FullNm],InStr([FullNm]," ")+1) & ", " & Left([FullNm],InStr([FullNm]," ")-1)


This only works if the [FullNm] field contains two names.