兄弟,<STRIKE>又</STRIKE>试着做了一个,见笑了。不过我用的是OFFICE2007,版本太高,就不上传了。记着先引用DAO 3。6 代码如下
Private Sub 命令0_Click()
DoCmd.SetWarnings False
Dim MYDB As DAO.Database
Set MYDB = CurrentDb
Dim MYRSTMT As DAO.Recordset
Dim MYRSTMM As DAO.Recordset
Dim MYRSTMS As DAO.Recordset
Dim MYSTRMT, MYSTRMM, MYSTRMS, SS As String
SS = ""
MYSTRMT = "结果"
Set MYRSTMT = MYDB.OpenRecordset(MYSTRMT)
MYSTRMS = "DELETE * FROM 结果;"
MYDB.Execute MYSTRMS
MYSTRMS = "INSERT INTO 结果 (dq,fz) SELECT dq ,fz FROM A GROUP BY dq,fz;"
MYDB.Execute MYSTRMS
MYRSTMT.MoveFirst
Do While Not MYRSTMT.EOF
MYSTRMM = "SELECT * FROM A WHERE DQ='" & MYRSTMT!DQ & "'"
Set MYRSTMM = MYDB.OpenRecordset(MYSTRMM)
MYRSTMM.MoveFirst
Do While Not MYRSTMM.EOF
SS = SS & vbCrLf & MYRSTMM("XM") MYRSTMM.MoveNext
Loop
MYRSTMT.EDIT MYRSTMT!XM = SS
MYRSTMT.Update
SS = ""
MYRSTMT.MoveNext
Loop
MYRSTMM.Close
MYRSTMT.Close
MYDB.Close
Set MYRSTMM = Nothing
Set MYRSTMS = Nothing
Set MYRSTMT = Nothing
DoCmd.SetWarnings True
DoCmd.OpenTable "结果"
End Sub
[此贴子已经被作者于2007-6-11 22:21:51编辑过]
|