INF: Function to Return a Variant's Data Type NameArticle ID: Q120496Creation Date: 13-SEP-1994 Revision Date: 19-SEP-1996
The information in this article applies to:
SUMMARY
Moderate: Requires basic macro, coding, and interoperability skills.
The VarType() function returns a number (from 0 to 8) indicating the data
type used to store a Variant in Access Basic. This article describes a
sample user-defined Access Basic function that you can use to return a text
description of the data type, instead of just a number.
This article assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools provided
with Microsoft Access. For more information on Access Basic, please refer
to the "Introduction to Programming" manual in Microsoft Access version
1.x, or the "Building Applications" manual in version 2.0.
MORE INFORMATION
The following table lists the numbers returned by the VarType() function
and their data type descriptions:
Number Returned Data Type Description
---------------------------------------
0 Empty
1 Null
2 Integer
3 Long
4 Single
5 Double
6 Currency
7 Date
8 String
The following steps demonstrate how to set up the sample function
DataTypeName():
NOTE: In the following sample code, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in Access Basic.
?DataTypeName((Date())) The function returns "Date," indicating the Date/Time data type.
?DataTypeName(Str$(1234.56)) Note that the function returns "String," indicating a String data type.
Note that the function returns "Double," indicating a Double data type.
REFERENCES Microsoft Access "Language Reference," version 1.1, pages 65 and 492-495 |
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.