比如:
access中名为:Table的表中存放需要建表的参数,如下:
ID ,表名,字段ID,字段名,字段类型,长度,小数位数,主键标志
1,a表,1,客户号,Text,10, ,primary key,
2,a表,2,客户名,Text,20, , ,
3,a表,2,客户本期余额,Double,10,2 , ,
4,b表,1,供应商号,Text,10, ,primary key,
5,b表,2,供应商名,Text,20, , ,
6,b表,3,供应商详细描述,Memo, , , ,
7,c表,1,排队号,Text,10, ,primary key,
8,c表,2,排队人名,Text,20, , ,
9,c表,3,排队人缴款金额,Currency, , , ,
实际中,有上百张表,而且每张表的字段数量都在20个以上,有的达到100多个字段,表名和字段参数都存在Table表中;
下面的代码运行时错误'-2147217900 (80040e14)':CREATE TABLE 语句中的语法错误,求高人帮助,谢谢!
'窗体->命令按钮->事件生成器
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("select * from tta order by 表名,字段ID")
abm = rs(1)
aa1 = "create table [" & rs(1) & "]("
Do While Not rs.EOF
If rs(1) = abm Then
aa1 = aa1 & "[" & rs(3) & "] " & rs(4) & " ( " & rs(5) & " ) )"
Else
aa1 = Left(aa1, Len(aa1) - 1) & ")"
CurrentProject.Connection.Execute aa1
abm = rs(1)
rs.MovePrevious
aa1 = "create table [" & abm & "]("
End If
rs.MoveNext
If rs.EOF() Then
aa1 = Left(aa1, Len(aa1) - 1) & ")"
CurrentProject.Connection.Execute aa1
End If
Loop |