Some people often ask how to obtain the access table structure.
- Public sub gettables ()
- Dim RS as new ADODB. recordset
- Dim conn as ADODB. Connection
- Dim ssql as string
- Set conn = currentproject. Connection
- Ssql = "select ID, name from msysobjects where type = 1 and flags = 0"
- Rs. Open ssql, Conn
- Do while not Rs. EOF
- Debug. Print "*****"; RS. Fields ("name"). value ;"****************"
- Gettablecolumns Rs. Fields ("name"). Value
- Rs. movenext
- Loop
- Rs. Close
- Set rs = nothing
- Set conn = nothing
- End sub
- Public sub gettablecolumns (stablename as string)
- Dim RS as new ADODB. recordset
- Dim conn as ADODB. Connection
- Dim metadata as ADODB. Field
- Set conn = currentproject. Connection
- Rs. Open stablename, Conn, adcmdtable
- For each errors in RS. Fields
- Debug. Print consumer. Name, sfldtype (consumer. type), consumer. numericscale, consumer. Precision
- Next
- Rs. Close
- Set rs = nothing
- Set conn = nothing
- End sub
- Public Function sfldtype (itype as integer)
- Select case itype
- Case 20
- Sfldtype = "bigint"
- Case 1, 128
- Sfldtype = "binary"
- Case 11
- Sfldtype = "Boolean"
- Case 8
- Sfldtype = "BSTR"
- Case 1, 136
- Sfldtype = "chapter"
- Case 1, 129
- Sfldtype = "char"
- Case 6
- Sfldtype = "currency"
- Case 7
- Sfldtype = "date"
- Case 1, 133
- Sfldtype = "dbdate"
- Case 1, 134
- Sfldtype = "dbtime"
- Case 1, 135
- Sfldtype = "dbtimestamp"
- Case 14
- Sfldtype = "decimal"
- Case 5
- Sfldtype = "double"
- Case 0
- Sfldtype = "empty"
- Case 10
- Sfldtype = "error"
- Case 64
- Sfldtype = "filetime"
- Case 72
- Sfldtype = "guid"
- Case 9
- Sfldtype = "idispatch"
- Case 3
- Sfldtype = "integer"
- Case 13
- Sfldtype = "iunknown"
- Case 1, 205
- Sfldtype = "longvarbinary"
- Case 1, 201
- Sfldtype = "longvarchar"
- Case 1, 203
- Sfldtype = "longvarwchar"
- Case 1, 131
- Sfldtype = "numeric"
- Case 1, 138
- Sfldtype = "propvariant"
- Case 4
- Sfldtype = "single"
- Case 2
- Sfldtype = "smallint"
- Case 16
- Sfldtype = "tinyint"
- Case 21
- Sfldtype = "unsignedbigint"
- Case 19
- Sfldtype = "unsignedint"
- Case 18
- Sfldtype = "unsignedsmallint"
- Case 17
- Sfldtype = "unsignedtinyint"
- Case 1, 132
- Sfldtype = "userdefined"
- Case 1, 204
- Sfldtype = "varbinary"
- Case 1, 200
- Sfldtype = "varchar"
- Case 12
- Sfldtype = "variant"
- Case 1, 139
- Sfldtype = "varnumeric"
- Case 1, 202
- Sfldtype = "varwchar"
- Case 1, 130
- Sfldtype = "wchar"
- Case else
- Sfldtype = "unknown"
- End select
- End Function