Office中国论坛/Access中国论坛
标题:
VBA ADD Fields
[打印本页]
作者:
access8009
时间:
2008-6-30 13:00
标题:
VBA ADD Fields
Public Sub AddMyFields()
Const csCoreSQL As String = "ALTER TABLE tblSomeTable ADD COLUMN "
Dim aStrField(10) As String
Dim x As Integer
'List of fields and datatypes
aStrField(0) = "Field1 CHARACTER(50)" 'Text Field
aStrField(1) = "Field2 INT" 'Number/Long
aStrField(2) = "Field3 SMALLINT" 'Number/Integer
aStrField(3) = "Field4 FLOAT" 'Number/Double
aStrField(4) = "Field5 REAL" 'Number/Single
aStrField(5) = "Field6 TINYINT" 'Number/Byte
aStrField(6) = "Field7 DECIMAL" 'Number/Decimal
aStrField(7) = "Field8 CURRENCY" 'Currency"
aStrField(8) = "Field9 BIT" 'Yes/No
aStrField(9) = "Field10 TEXT" 'Memo (you can use MEMO too)
aStrField(10) = "Field11 IMAGE" 'OLE Object
'Form and execute the DDL statement
With CurrentProject.Connection
For x = 0 To UBound(aStrField)
.Execute csCoreSQL & aStrField(x)
Next x
End With
End Sub
作者:
tanhong
时间:
2008-6-30 14:39
好东还真是不少,[:50]
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3