周报表,让我纠结了好几天,今天做一点点,发现实现不了,于是又留到第二天,就这样,一个报表让我挂了大概四五天吧。
1:点击“插入”——分别选择“报表头、报表尾、页眉、明细网格”
3:点击“插入”——选择“综合文字框”,在综合文字框中设置参数“StartData”和“EndData”
即: EndData同StartData一样
在这里点击“测试”后可能会出现这样一个窗体:
第一:换一种连接方式,用sa身份验证、windows身份验证、OLEDB连接数据库、ODBC连接数据库等;
这样就完成了对报表的建立,剩下的,也就是VB与报表连接,在VB中,报表的显示问题。
Dim WithEvents Report As grproLibCtl.GridppReport '实例化报表
WithEvents注意:处理时间源所引发的事件
Private Sub Form_Load() '创建报表对象 Set Report = New grproLibCtl.GridppReport '载入报表模版文件 Report.LoadFromFile (App.Path & "\周报表.grf") '设置数据连接串 Report.DetailGrid.Recordset.ConnectionString = "provider=sqlOLEDB;server=zhudan-pc;database=charge1_sys;integrated security =SSPI" '用来使grdWeekliyBill报表查询器控件显示报表中的内容 grdWeekliyBill.Report = Report grdWeekliyBill.Start Report.ParameterByName("StartDate").Value = Format$(StartDateView.Value,"yyyy-mm-dd") Report.ParameterByName("EndDate").Value = Format$(EndDateView.Value,"yyyy-mm-dd") '日期控件不可见 StartDateView.Visible = False EndDateView.Visible = False End Sub刷新: @H_403_19@
Private Sub cmdRefresh_Click() '账单刷新
Dim strsql As String
Dim strMsg As String
Dim objRsWeekliyBill As ADODB.Recordset
Dim objRsDaliyBill As ADODB.Recordset
If StartDateView.Value > EndDateView.Value Then '条件限制
MsgBox "终止日期不能小于起始日期!",vbOKOnly + vbExclamation,"警告"
Exit Sub
End If
'日期的选定
strsql = "select * from DayCheckInfo where date between'" & Format$(StartDateView.Value,"yyyy - mm - dd") & "'" & " and'" & Format$(EndDateView.Value,"yyyy-mm-dd") & "'"
Set objRsDaliyBill = Executesql(strsql,strMsg)
strsql = "select * from WeekCheckInfo"
Set objRsWeekliyBill = Executesql(strsql,strMsg)
Do While objRsWeekliyBill.EOF = False
objRsWeekliyBill.Delete
objRsWeekliyBill.MoveNext
Loop
'更新到日结表中
Do While objRsDaliyBill.EOF = False '判断是否有数据
With objRsWeekliyBill
.AddNew
.Fields(0) = objRsDaliyBill.Fields(0)
.Fields(1) = objRsDaliyBill.Fields(1)
.Fields(2) = objRsDaliyBill.Fields(2)
.Fields(3) = objRsDaliyBill.Fields(3)
.Fields(5) = objRsDaliyBill.Fields(4)
.Fields(4) = objRsDaliyBill.Fields(5)
.Update
objRsDaliyBill.MoveNext
End With
Loop
grdWeekliyBill.Refresh '刷新
Report.DetailGrid.Recordset.Querysql = "select * from weekcheckinfo where date between '" & StartDateView.Value & "' and '" & EndDateView.Value & "'"