Microsoft KB Archive/109708

From BetaArchive Wiki
Knowledge Base


ACC: Applying String Functions to Numeric Data Types

Article ID: 109708

Article Last Modified on 1/18/2007



APPLIES TO

  • Microsoft Access 1.0 Standard Edition
  • Microsoft Access 1.1 Standard Edition
  • Microsoft Access 2.0 Standard Edition
  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition



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.

Keywords: kbinfo kbusage KB109708