Get the name of an ADO data type from the recordset.field.type property? Get the name of an ADO data type from the recordset.field.type property? vba vba

Get the name of an ADO data type from the recordset.field.type property?


The answers in the comments under the question (above) are excellent, unfortunately they boil down to "you can't get there from here." There is no simple way to get the data type contained in a Field. The closest I was able to come was to do this for the quick-n-dirty:

Function Scripting()    Dim rs As DAO.Recordset    Dim ff As String    Dim fieldType As String    ff = "c:\Users\me\Desktop\Structure.txt"    Open ff For Output As #1    Set rs = CurrentDb.OpenRecordset("myTable")    For x = 0 To rs.Fields.Count - 1        Print #1, rs.Fields(x).Name & vbTab & TypeName(rs.Fields(x).Value) & vbTab & rs.Fields(x).Size    Next    Close #1    rs.Close    Set rs = NothingEnd Function

You would be well advised go to Allen Browne's excellent page and grab his FieldTypeName() function for a better solution.

Thanks to everyone (mehow, blackhawk, Chris Rolliston and Tim Williams) that chipped in on the answer.