|
- Dim rs As New ADODB.Recordset
- Dim strSQL As String, SQL As String
- Dim strOrigin() As String
- Dim I As Integer, J As Integer, K As Integer
- Dim strTableName As String
- strSQL = "select distinct 籍贯 from 档案"
- rs.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
- I = rs.RecordCount - 1
- ReDim strOrigin(I) As String
- For J = 0 To I
- strOrigin(J) = rs.Fields(0)
- rs.MoveNext
- Next
- rs.Close
- Set rs = Nothing
- For K = 0 To UBound(strOrigin)
- strTableName = strOrigin(K)
- SQL = "select * into " & strTableName & " from 档案 where 籍贯='" & strOrigin(K) & "'"
- CurrentDb.Execute SQL
- DoCmd.OutputTo acOutputTable, strTableName, acFormatXLS, CurrentProject.Path & "" & strTableName & ".xls"
- DoCmd.DeleteObject acTable, strTableName
- Next
复制代码
[ 本帖最后由 Henry D. Sy 于 2008-12-6 00:00 编辑 ] |
|