|
2#
楼主 |
发表于 2009-3-23 22:55:41
|
只看该作者
自己写了一段,可以了,但觉得很菜,请大侠修改
Dim ry, rst As Recordset
Dim sql As String
100:
Set rst = CurrentDb.OpenRecordset("收入情况", dbOpenDynaset)
a = rst.Fields.Count
sql = "SELECT 人员.姓名 FROM 人员 WHERE 岗位='营销员';"
Set ry = CurrentDb.OpenRecordset(sql)
Do Until ry.EOF
b = 0
For Each fld In rst.Fields
If ry("姓名") = fld.Name Then
GoTo 10
End If
b = b + 1
Next
If b = a Then
c = ry("姓名")
rst.Close
CurrentDb.Execute "ALTER TABLE 收入情况 ADD COLUMN " & c & " float;"
GoTo 100
End If
10:
ry.MoveNext
Loop |
|