ACC: Applying String Functions to Numeric Data Types

Last reviewed: December 2, 1997
Article ID: Q109708
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

Novice: Requires knowledge of the user interface on single-user computers.

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          : ExrOthr kbusage
Version           : 1.0 1.1 2.0 7.0
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbinfo


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.