Public Sub fitSize()
Dim a()
Dim i As Integer
Dim j As Integer
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("w1")
j = rs.Fields.Count
ReDim a(j, 2)
For i = 0 To j - 1
a(i, 1) = rs.Fields(i).Name
a(i, 2) = DMax("len(trim(" & rs.Fields(i).Name & "))", "w1")
Next
rs.Close
Set rs = Nothing
For i = 1 To j - 1
db.Execute "alter table w1 alter column " & a(i, 1) & " char(" & a(i, 2) & ")"
Next
End Sub作者: fang123 时间: 2008-3-28 22:29
再次谢谢kangking的帮助,又快又准.要浪费您宝贵的时间真的很抱歉,终于解决了心头中的困惑.向您学习了!