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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to extract Access table schema with decimal places on numeric fields?

Status
Not open for further replies.

BugZap13

Programmer
Dec 2, 2013
30
US
In a VBA module within an Access database I am trying to create a query which needs the schema information for a table. I can get the field names, type and size but cannot get the decimal places for the various numeric types. Anyone have a clue how to get the field properties as seen in design mode?

Following are a couple of failed tries which do not give me the decimal places for the various fields.
Code:
Private Function GetSchema1(tcTable As String)
Dim oDatabase As Database, oTabledef As TableDef
Set oDatabase = CurrentDb()
Set oTabledef = oDatabase.TableDefs(tcTable)

For Each oField In oTabledef.Fields
   a = 1
Next oField
End Function

Code:
Private Function CreateSQL(tcTable As String)
Dim cSQL As String, oDatabase As Database, oRecordset As Recordset
cSQL = "SELECT * FROM " + tcTable + " WHERE 1=0"
Set oDatabase = CurrentDb()
Set oRecordset = oDatabase.OpenRecordset(cSQL, dbOpenDynaset)
Dim iFields As Integer, oField As Object, cFieldName As String
For iFields = 0 To oRecordset.Fields.Count - 1
   Set oField = oRecordset.Fields(iFields)
   With oField
   cFieldName = .Name
   Select Case .Type
   Case Is = dbBigInt
   End With
Next iFields
End Function

TIA, Mark
 
Please post in Forum700

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
AD1D550E-FCB5-4AB6-A3C8-1F86CACE2554_ne1bcz.jpg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top