Private Sub Command1_Click()
dim i as integer
On Error Resume Next '这一句错误处理要有,因为加载控件数组可能会出错,其实你只要设计一个label1(0)即可
With Adodc1
.ConnectionString = Conn
.RecordSource = "select count(distinct hhh),sum(qq) FROM ttt_view where
" & _
"
time>='" & Trim(DTPicker1.Value) & "' " & _
" and time<='" & Trim(DTPicker2.Value) & "' " & _
" and doc like'" & DataCombo2.BoundText & "%" & "'" & _
" and cm like'" & DataCombo1.BoundText & "%" & "' group by hhh "
.Refresh
End With
For i = 0 To Adodc4.Recordset.Fields.Count - 1
Unload Label1(i + 1)
Load Label1(i + 1)
Label1(i + 1).Top = Label1(0).Top + (i + 1) * Label1(0).Height
Label1(i + 1).Visible = True
Label1(i + 1).Caption = Adodc4.Recordset.Fields(i)
'以label1(0)为基准,竖着排下来显示各字段值
Next i
'不过,你前面是对数据库控件Adodc1创建记录集,怎么在for循环里又对Adodc4进行操作了,除非你加载了好多数据库控件
End Sub
[
本帖最后由 lowxiong 于 2011-5-27 19:53 编辑 ]