Private Sub Command1_Click()
' Option1(0).Value = True
Sum单元 = 0
Set Newxls_基数 = CreateObject("excel.application")
'创建Excel应用程序并打开之
Newxls_基数.Workbooks.Open (App.Path & "\项目基本数据.xls")
'打开EXCEL工作簿
For i = 0 To 15
Newxls_基数.Worksheets(i + 1).Select '选择工作表
Newxls_基数.Rows("1:5000").Clear
'清除表格内容
Next i
Dim MyStr$
MyStr = "项目名称='" & Str项目名 & "'"
For i = 0 To 15
If i = 0 Then SQL = "select * from 田地平整表 where " & MyStr
If i = 1 Then SQL = "select * from 道路基数表 where " & MyStr
If i = 2 Then SQL = "select * from 涵表 where " & MyStr
If i = 3 Then SQL = "select * from 桥基数表 where " & MyStr
If i = 4 Then SQL = "select * from 水源基数表 where " & MyStr
If i = 5 Then SQL = "select * from 输水基数表 where " & MyStr
If i = 6 Then SQL = "select * from 泵站基数表 where " & MyStr
If i = 7 Then SQL = "select * from 岸坡基数表 where " & MyStr
If i = 8 Then SQL = "select * from 坡面基数表 where " & MyStr
If i = 9 Then SQL = "select * from 造林基数表 where " & MyStr
If i = 10 Then SQL = "select * from 其它基数表 where " & MyStr
If i = 11 Then SQL = "select * from 单元序号表 where " & MyStr & " order by 单ID "
If i = 12 Then SQL = "select * from 分部序号表 where " & MyStr & " order by 分ID "
If i = 13 Then SQL = "select * from 单位序号表 where " & MyStr & " order by 位ID "
If i = 14 Then SQL = "select * from 隐蔽序号表 where " & MyStr & " order by 隐ID "
If i = 15 Then SQL = "select * from 坐标序号表 where " & MyStr & " order by 坐标ID "
Adodc1(i).CommandType = adCmdUnknown
Adodc1(i).RecordSource = SQL
Adodc1(i).Refresh
Set DataGrid1.DataSource = Adodc1(i)
If Adodc1(i).Recordset.RecordCount > 0 Then OutToExcel单元基础数 DataGrid1, i
'这地方不能有“(”,有则显示出错!!!
Next i
Newxls_基数.Visible = True
'设置EXCEL可见
'
Newxls_基数.Visible = True
'设置EXCEL可见
End Sub