Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to get the data types of fields in access database with VBA?
How to get the data types of fields in access database with VBA?
1. Open the corresponding access database.

2. Click the module in the object bar on the left and observe the window on the right. If there is a module in it, you can double-click to open it. If a new module has not been created, double-click it to open it.

3. Paste the following code to run and observe the instant window.

Private? Sub? aaaa()

Dim? TableName? As? String,? Field name? As? String,? Me? As? integer

TableName? =? “tb 1”? Table name? tb 1

Field name? =? "Numbers"? Field name? figure

Choice? Case? CurrentDb。 TableDefs(TableName)(FieldName)。 type

Case? dbBoolean

Debugging. Print? "Yes/No"

Case? dbByte

Debugging. Print? "Number (bytes)"

Case? dbInteger

Debugging. Print? "Number (integer)"

Case? dbLong

What if? (CurrentDb。 TableDefs(TableName)(FieldName)。 Attribute? And then what? dbAutoIncrField)? =? dbAutoIncrField? then

Debugging. Print? "Automatic numbering (long integer)"

other

Debugging. Print? "Number (long integer)"

End? if

Case? dbSingle

Debugging. Print? "Digital (single precision)"

Case? dbDouble

Debugging. Print? "Digital (Double Precision)"

Case? dbDecimal

Debugging. Print? "Number (decimal)"

Case? dbCurrency

Debugging. Print? "money"

Case? Database date

Debugging. Print? "Date/Time"

Case? dbText

Debugging. Print? "Text"

Case? Database memorandum

What if? (CurrentDb。 TableDefs(TableName)(FieldName)。 Attribute? And then what? dbHyperlinkField)? =? dbHyperlinkField? then

Debugging. Print? "Hyperlink"

other

Debugging. Print? "Remarks"

End? if

Case? dbGUID

Debugging. Print? "Automatic numbering (automatic copy ID)"

End? choose

End? submarine