rapidly change data type of table in Access 2007
I have a table with >100 columns imported from excel to access 2007, and I want to change all the datatype of the fields into memo, being fed up of manually clicking the datatype pull down list one by one, can I do it by VBA or SQL sta开发者_JAVA百科tement? Thanks!
I fixed it finally:
Dim db As DAO.Database
Dim tdf1 As DAO.TableDef
Dim fld As DAO.Field
Set db = CurrentDb
Set tdf = CurrentDb.OpenRecordset("ssi_10q12_v5_table")
Set tdf1 = db.CreateTableDef("ssi_10q12_v5_table_1")
Debug.Print tdf.Name,
Debug.Print tdf.Fields.Count
For x = 0 To tdf.Fields.Count - 1
Debug.Print tdf.Fields(x).Name,
Set fld = tdf1.CreateField(tdf.Fields(x).Name, dbMemo)
tdf1.Fields.Append fld
Next x
db.TableDefs.Append tdf1
Set fld = Nothing
Set tdf = Nothing
End Sub
See if this can help anyone here, thanks again.
精彩评论