Obtain the Access Table Structure

Source: Internet
Author: User
Some people often ask how to obtain the access table structure.
  1. Public sub gettables ()
  2. Dim RS as new ADODB. recordset
  3. Dim conn as ADODB. Connection
  4. Dim ssql as string
  5. Set conn = currentproject. Connection
  6. Ssql = "select ID, name from msysobjects where type = 1 and flags = 0"
  7. Rs. Open ssql, Conn
  8. Do while not Rs. EOF
  9. Debug. Print "*****"; RS. Fields ("name"). value ;"****************"
  10. Gettablecolumns Rs. Fields ("name"). Value
  11. Rs. movenext
  12. Loop
  13. Rs. Close
  14. Set rs = nothing
  15. Set conn = nothing
  16. End sub
  17. Public sub gettablecolumns (stablename as string)
  18. Dim RS as new ADODB. recordset
  19. Dim conn as ADODB. Connection
  20. Dim metadata as ADODB. Field
  21. Set conn = currentproject. Connection
  22. Rs. Open stablename, Conn, adcmdtable
  23. For each errors in RS. Fields
  24. Debug. Print consumer. Name, sfldtype (consumer. type), consumer. numericscale, consumer. Precision
  25. Next
  26. Rs. Close
  27. Set rs = nothing
  28. Set conn = nothing
  29. End sub
  30. Public Function sfldtype (itype as integer)
  31. Select case itype
  32. Case 20
  33. Sfldtype = "bigint"
  34. Case 1, 128
  35. Sfldtype = "binary"
  36. Case 11
  37. Sfldtype = "Boolean"
  38. Case 8
  39. Sfldtype = "BSTR"
  40. Case 1, 136
  41. Sfldtype = "chapter"
  42. Case 1, 129
  43. Sfldtype = "char"
  44. Case 6
  45. Sfldtype = "currency"
  46. Case 7
  47. Sfldtype = "date"
  48. Case 1, 133
  49. Sfldtype = "dbdate"
  50. Case 1, 134
  51. Sfldtype = "dbtime"
  52. Case 1, 135
  53. Sfldtype = "dbtimestamp"
  54. Case 14
  55. Sfldtype = "decimal"
  56. Case 5
  57. Sfldtype = "double"
  58. Case 0
  59. Sfldtype = "empty"
  60. Case 10
  61. Sfldtype = "error"
  62. Case 64
  63. Sfldtype = "filetime"
  64. Case 72
  65. Sfldtype = "guid"
  66. Case 9
  67. Sfldtype = "idispatch"
  68. Case 3
  69. Sfldtype = "integer"
  70. Case 13
  71. Sfldtype = "iunknown"
  72. Case 1, 205
  73. Sfldtype = "longvarbinary"
  74. Case 1, 201
  75. Sfldtype = "longvarchar"
  76. Case 1, 203
  77. Sfldtype = "longvarwchar"
  78. Case 1, 131
  79. Sfldtype = "numeric"
  80. Case 1, 138
  81. Sfldtype = "propvariant"
  82. Case 4
  83. Sfldtype = "single"
  84. Case 2
  85. Sfldtype = "smallint"
  86. Case 16
  87. Sfldtype = "tinyint"
  88. Case 21
  89. Sfldtype = "unsignedbigint"
  90. Case 19
  91. Sfldtype = "unsignedint"
  92. Case 18
  93. Sfldtype = "unsignedsmallint"
  94. Case 17
  95. Sfldtype = "unsignedtinyint"
  96. Case 1, 132
  97. Sfldtype = "userdefined"
  98. Case 1, 204
  99. Sfldtype = "varbinary"
  100. Case 1, 200
  101. Sfldtype = "varchar"
  102. Case 12
  103. Sfldtype = "variant"
  104. Case 1, 139
  105. Sfldtype = "varnumeric"
  106. Case 1, 202
  107. Sfldtype = "varwchar"
  108. Case 1, 130
  109. Sfldtype = "wchar"
  110. Case else
  111. Sfldtype = "unknown"
  112. End select
  113. End Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.