ACC: Applying String Functions to Numeric Data Types (109708)



The information in this article applies to:

  • Microsoft Access 1.0
  • Microsoft Access 1.1
  • Microsoft Access 2.0
  • Microsoft Access for Windows 95 7.0
  • Microsoft Access 97

This article was previously published under Q109708
Novice: Requires knowledge of the user interface on single-user computers.

SUMMARY

When you apply the Left() or Mid() function to a numeric data type that has been converted to a string, you must account for the algebraic sign in the value's leftmost position.

MORE INFORMATION

The algebraic sign in the leftmost position of an integer value is either a space (for positive numbers) or a minus sign (for negative numbers). Note that if the value is positive, you can use the Trim() function to remove the space.

The following list shows what will be returned when string functions such as Left(), Mid(), or Right() are applied to integers:
   Function                       Returns    Data Type
   ---------------------------------------------------
   Mid$(Str$(1234),1,1)           " "        String
   Mid$(Trim(Str$(1234)),1,1)     "1"        String
   Mid$(Str$(1234),2,1)           "1"        String
   Mid$(Trim(Str$(1234)),2,1)     "2"        String
   Mid$(Str$(-1234),1,1)          "-"        String
   Mid$(Trim(Str$(-1234)),1,1)    "-"        String
   Mid$(Trim(Str$(+1234)),1,1)    "1"        String
   Mid$(Trim(Str$(-1234)),1,2)    "-1"       String
   Right$(Str$(1234),4)           "1234"     String
   Right$(Str$(1234),5)           " 1234"    String
   Left$(Str$(1234) ,1)           " "        String
   Left$(Trim(Str$(1234)),1)      "1"        String
   Left$(Str$(1234),2)            " 1"       String
   Left$(Trim(Str$(1234)),2)      "12"       String
   Left$(Str$(-1234),1)           "-"        String
   Left$(Trim(Str$(-1234)),1)     "-"        String
   Left$(Trim(Str$(+1234)),1)     "1"        String
   Left$(Trim(Str$(+1234)),2)     "-1"       String
   Len(Str$(1234))                5          Long
   Len(Trim(Str$(1234)))          4          Long
				

NOTE: The quotation marks in the list above are not returned by the functions. They are used here to help show blank, or space, characters.

REFERENCES

For more information about string functions, search for "Left," "Right," "Mid," or "Trim" using the Microsoft Access Help menu.

Modification Type:MajorLast Reviewed:5/6/2003
Keywords:kbinfo kbusage KB109708