list of data types Ms Access Gurus

VBA > custom Function > GetDataType

Return the string name or abbreviation of a numeric data type.

Custom Function (also known as UDF, User-Defined Function)

Show the data type name or abbreviation instead of a number.

show the data type name or abbreviation instead of a number

Goto Top  

Code

Code to get a data type name or abbreviation

Option Compare Database 
Option Explicit 

'*************** Code Start *****************************************************
' module name: mod_GetDataType_s4p
'  http://msaccessgurus.com/VBA/Code/fx_GetDataType.htm
'-------------------------------------------------------------------------------
' Purpose  : return string  description of a nu meric data type
' Author   : crystal (strive4peace)
' Return   : string
' License  : below code
' Code List: www.msaccessgurus.com/code.htm
'-------------------------------------------------------------------------------

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'           GetDataType
'                 use if you don't have a DataTypes table
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function GetDataType(ByVal piDataType As Integer _ 
   ,Optional pBooShort As Boolean = False _ 
   ) As String 

'100310, 190520 integer from DD

   GetDataType =  ""
   On Error Resume Next 

   Switch 
   Select Case Nz(piDataType) 
      Case 1: GetDataType = IIf(pBooShort, "YN", "Boolean") 
      Case 2: GetDataType = IIf(pBooShort, "Byt", "Byte") 
      Case 3: GetDataType = IIf(pBooShort, "Int", "Integer") 
      Case 4: GetDataType = IIf(pBooShort, "Lng", "Long") 
      Case 5: GetDataType = IIf(pBooShort, "Cur", "Currency") 
      Case 6: GetDataType = IIf(pBooShort, "Sgl", "Single") 
      Case 7: GetDataType = IIf(pBooShort, "Dbl", "Double") 
      Case 8: GetDataType = IIf(pBooShort, "DatT", "DateTime") 
      Case 10: GetDataType = IIf(pBooShort, "Txt", "Text") 
      Case 12: GetDataType = IIf(pBooShort, "Mem", "Long Text") 

      Case 9: GetDataType = IIf(pBooShort, "Bin", "Binary") 
      Case 11: GetDataType = IIf(pBooShort, "Ole", "Ole BinBMP") 

      Case 15: GetDataType = IIf(pBooShort, "Guid", "GUID") 
      Case 16: GetDataType = IIf(pBooShort, "BigInt", "BigInt") 
      Case 17: GetDataType = IIf(pBooShort, "BinVar", "Binary Variable") 

      Case 18: GetDataType = IIf(pBooShort, "TxtFix", "Fixed Text") 

      Case 19: GetDataType = IIf(pBooShort, "oNum", "Numeric odbc") 
      Case 20: GetDataType = IIf(pBooShort, "oDec", "Decimal odbc") 
      Case 21: GetDataType = IIf(pBooShort, "oFlo", "Float odbc") 
      Case 22: GetDataType = IIf(pBooShort, "oTime", "Time odbc") 
      Case 23: GetDataType = IIf(pBooShort, "oDatT", "DateTime odbc") 

      Case 101: GetDataType = IIf(pBooShort, "att", "Attachment") 
      Case 102: GetDataType = IIf(pBooShort, "mvByt", "multi Byte") 
      Case 103: GetDataType = IIf(pBooShort, "mvInt", "multi Integer") 
      Case 104: GetDataType = IIf(pBooShort, "mvLng", "multi Long Integer") 
      Case 105: GetDataType = IIf(pBooShort, "mvSgl", "multi Single") 
      Case 106: GetDataType = IIf(pBooShort, "mvDbl", "multi Double") 
      Case 107: GetDataType = IIf(pBooShort, "mvGuid", "multi Guid") 
      Case 108: GetDataType = IIf(pBooShort, "mvDec", "multi Decimal") 
      Case 109: GetDataType = IIf(pBooShort, "mvTxt", "multi Text") 

      Case Else: GetDataType = Format(Nz(piDataType), "0") 
   End Select 
End Function 

'   You may freely use and share this code
'     provided this license notice and comment lines are not changed;
'     code may be modified provided you clearly note your changes.
'   You may not sell this code alone, or as part of a collection,
'     without my handwritten permission.
'   All ownership rights reserved. Use at your own risk.
'   ~ crystal (strive4peace)  www.msaccessgurus.com
'*************** Code End *******************************************************

Keywords and comments in code were colored with this free Color Code add-in

Goto Top  

Download

Click HERE to download the zipped BAS file containing the code above to get data type names.
(2 kb, unzips to a module BAS file)  

License

This code may be used freely, but you may not sell it in whole or in part. You may include it in applications you develop for others.

Share with others

here's the link for this page in case you want to copy it:
http://msaccessgurus.com/VBA/Code/fx_GetDataType.htm

Share your comments

Email me anytime at info@msAccessGurus.com. I love hearing about what you're doing with Access.

Are you looking for help with your application?

Let's connect and do it together. As needed, I'll pull in code and features from my vast libraries, cutting out lots of development time.

Or maybe you have graphics you want to be able to use on reports ... an image or logo that Access could draw? or maybe indicators like stoplights on records? That would be fun to figure out!

I'm happy to help you! I like working with people who want to do it themself, and just need someone to guide past the obstacles and teach better ways. For training and programming, email me at training@msAccessGurus.com

I look forward to hearing from you ~

~ crystal

Goto Top