主题:报表显示查询结果
单击 command1 查询 结果显示在 DataGrid1 表中
日期 型号 名称
2005-05-01 001002 小刀
2005-05-01 001003 尺子
2005-05-20 001002 小刀
2005-05-23 001005 笔记本
.
.
.
2005-05-30 001003 尺子
-----------------------------------
Private Sub Command1_Click()
Dim strSQL As String
On Error GoTo Err
strSQL = "Select * From 考勤记录 Where 日期>#" & DTPicker1 - 1 & "# and 日期<#" & DTPicker2 & "#"
Set Rs = New Recordset
Rs.Open strSQL, Conn, adOpenStatic, adLockBatchOptimistic
Set Adodc1.Recordset = Rs
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
Set Rs = Nothing
Exit Sub
Err:
MsgBox Err.Description
Set Rs = Nothing
end sub
-------------------------------------
单击 command2 显示报表
Private Sub Command2_Click()
DataReport1.Show
DataReport1.Sections(2).Controls("Label2").Caption = "开始日期:" & CStr(DTPicker1.Value)
DataReport1.Sections(2).Controls("Label3").Caption = "结束日期:" & CStr(DTPicker2.Value - 1)
End Sub
----------------------------
怎样才能把查询结果显示在 DataReport1 报表中呢?
高手教教我,非常感谢。
日期 型号 名称
2005-05-01 001002 小刀
2005-05-01 001003 尺子
2005-05-20 001002 小刀
2005-05-23 001005 笔记本
.
.
.
2005-05-30 001003 尺子
-----------------------------------
Private Sub Command1_Click()
Dim strSQL As String
On Error GoTo Err
strSQL = "Select * From 考勤记录 Where 日期>#" & DTPicker1 - 1 & "# and 日期<#" & DTPicker2 & "#"
Set Rs = New Recordset
Rs.Open strSQL, Conn, adOpenStatic, adLockBatchOptimistic
Set Adodc1.Recordset = Rs
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
Set Rs = Nothing
Exit Sub
Err:
MsgBox Err.Description
Set Rs = Nothing
end sub
-------------------------------------
单击 command2 显示报表
Private Sub Command2_Click()
DataReport1.Show
DataReport1.Sections(2).Controls("Label2").Caption = "开始日期:" & CStr(DTPicker1.Value)
DataReport1.Sections(2).Controls("Label3").Caption = "结束日期:" & CStr(DTPicker2.Value - 1)
End Sub
----------------------------
怎样才能把查询结果显示在 DataReport1 报表中呢?
高手教教我,非常感谢。