Office中国论坛/Access中国论坛

标题: 可否编程修改表中字段的属性设置 [打印本页]

作者: yangruilai    时间: 2002-12-8 05:09
标题: 可否编程修改表中字段的属性设置
可否编程修改表中字段的属性设置,如默认值等?
作者: txman    时间: 2002-12-8 06:46
可以。用DAO,好像ADO也可以
作者: yangruilai    时间: 2002-12-9 01:59
希望具体些!
作者: cattjiu    时间: 2002-12-9 16:00
Private Sub AddField_Click()
Dim dbs As Database
Dim tdf As TableDef
Dim fld1 As Field, fld2 As Field, fld3 As Field, fld4 As Field, fld5 As Field, fld6 As Field, fld7 As Field
Set dbs = CurrentDb
Set tdf = dbs.TableDefs("runapp")
Set fld1 = tdf.CreateField("RunNo", dbText, 6)
Set fld2 = tdf.CreateField("DimCust", dbText, 6)
Set fld3 = tdf.CreateField("DimProd", dbText, 6)
Set fld4 = tdf.CreateField("DimCost", dbText, 6)
Set fld5 = tdf.CreateField("DimInter", dbText, 6)
Set fld6 = tdf.CreateField("Curr", dbText, 6)
Set fld7 = tdf.CreateField("Dim5", dbText, 6)

tdf.Fields.Append fld1
tdf.Fields.Append fld2
tdf.Fields.Append fld3
tdf.Fields.Append fld4
tdf.Fields.Append fld5
tdf.Fields.Append fld6
tdf.Fields.Append fld7
dbs.TableDefs.Refresh

Set dbs = Nothing
MsgBox "OK"
End Sub






欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3