为什么ActiveX部件不能创建对象?
vb动态创建数据库,先在MSHFlexGrid1控件添加字段,然后将MSHFlexGrid1控件中的字段生成数据表,运行时出现 “实时错误429 ActiveX部件不能创建对象”提示。请师傅指点迷津!生成表的代码如下:
Private Sub Command2_Click() '生成数据库表
Dim PathName As String
PathName = App.Path
If Right(PathName, 1) <> "\" Then
PathName = PathName & "\"
End If
Dim aaa As Variant
Dim i As Integer
Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
Set MyDatabase = CreateDatabase(PathName & Text4.Text, dbLangGeneral)
Set MyTable = MyDatabase.CreateTableDef(Text2.Text)
For i = 1 To 12
If MSHFlexGrid1.TextMatrix(i, 1) <> "" Then
aaa = MSHFlexGrid1.TextMatrix(i, 2)
Set MyField = MyTable.CreateField(MSHFlexGrid1.TextMatrix(i, 1), aaa, 50)
MyTable.Fields.Append MyField
End If
Next i
MyDatabase.TableDefs.Append MyTable
End Sub