Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning datatype of a field in a Table

Status
Not open for further replies.

DoDo1975

Technical User
Jun 4, 2002
18
CA
Anybody know how to do a lookup of the datatype for a field in an access database? I want to bring the table name and field name in as variables and then lookup the datatype for that field.

Any help would be appreciated.

JL
 
Use DAO. Start by assigning CurrentDb() to a Database object variable. Then access the table definition from the TableDefs collection, and from that get the field definition from the Fields collection. The resulting Field object has a Type property that gives the field data type. Some of the possible values are dbText, dbMemo, dbLong, etc.

Note: An "autonumber" field will be of type dbLong. If you need to know whether a dbLong field is actually an autonumber, you'll also have to test the Field object's Attributes property, using the dbAutoIncrField bit mask. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top