如果是这样,先做一个查询1,内容为:SELECT 起运地.起运地 FROM 起运地 GROUP BY 起运地.起运地;
然后用下面的语句这样就ok了,生成的excel文件与数据库在同一个文件夹里。
Dim rs As Object
Set rs = CurrentDb.OpenRecordset("查询1")
Do Until rs.EOF
SQL = "select * into [Excel 8.0;database=" & CurrentProject.Path & "\" & rs(0) & ".xls]." & rs(0) & " from 起运地 where 起运地='" & rs(0) & "';"
CurrentDb.Execute SQL
rs.MoveNext
Loop
Set rs = Nothing