📄 datareport2.dsr
字号:
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
EndProperty
ItemType2 = 4
BeginProperty Item2 {1C13A8E2-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Text4"
Object.Left = 6236
Object.Width = 1140
Object.Height = 570
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Alignment = 1
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 1
Format = "#,##0.00"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 2
EndProperty
EndProperty
ItemType3 = 4
BeginProperty Item3 {1C13A8E2-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Text5"
Object.Left = 7937
Object.Width = 1125
Object.Height = 570
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Alignment = 1
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 1
Format = "0.0%"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 5
EndProperty
EndProperty
ItemType4 = 4
BeginProperty Item4 {1C13A8E2-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Text1"
Object.Left = 1701
Object.Width = 1140
Object.Height = 570
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Alignment = 1
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
ItemType5 = 4
BeginProperty Item5 {1C13A8E2-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Text6"
Object.Left = 9638
Object.Width = 1125
Object.Height = 570
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Alignment = 1
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 1
Format = "#,##0.00"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 2
EndProperty
EndProperty
ItemType6 = 5
BeginProperty Item6 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Line9"
Object.Left = 1701
Object.Height = 555
EndProperty
ItemType7 = 5
BeginProperty Item7 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Line16"
Object.Left = 9638
Object.Height = 555
EndProperty
ItemType8 = 5
BeginProperty Item8 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Line17"
Object.Left = 7937
Object.Height = 555
EndProperty
ItemType9 = 5
BeginProperty Item9 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Line18"
Object.Left = 6236
Object.Height = 555
EndProperty
ItemType10 = 5
BeginProperty Item10 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Line19"
Object.Left = 4536
Object.Height = 555
EndProperty
ItemType11 = 5
BeginProperty Item11 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Line20"
Object.Left = 3402
Object.Height = 555
EndProperty
ItemType12 = 5
BeginProperty Item12 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Line3"
Object.Left = 1701
Object.Top = 567
Object.Width = 9075
EndProperty
ItemType13 = 5
BeginProperty Item13 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Line10"
Object.Left = 10772
Object.Height = 555
EndProperty
EndProperty
SectionCode3 = 7
BeginProperty Section3 {1C13A8E0-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Section3"
Object.Height = 735
KeepTogether = -1 'True
NumControls = 5
ItemType0 = 3
BeginProperty Item0 {1C13A8E1-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Label8"
Object.Left = 1701
Object.Width = 1140
Object.Height = 570
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Object.Caption = "合计"
EndProperty
ItemType1 = 3
BeginProperty Item1 {1C13A8E1-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Labela3"
Object.Left = 4535
Object.Width = 1140
Object.Height = 570
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Object.Caption = "0"
EndProperty
ItemType2 = 3
BeginProperty Item2 {1C13A8E1-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Labela4"
Object.Left = 6236
Object.Width = 1125
Object.Height = 570
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Object.Caption = "0"
EndProperty
ItemType3 = 3
BeginProperty Item3 {1C13A8E1-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Labela5"
Object.Left = 7937
Object.Width = 1134
Object.Height = 567
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Object.Caption = "0"
EndProperty
ItemType4 = 3
BeginProperty Item4 {1C13A8E1-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Labela6"
Object.Left = 9638
Object.Width = 1134
Object.Height = 567
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Object.Caption = "0"
EndProperty
EndProperty
SectionCode4 = 8
BeginProperty Section4 {1C13A8E0-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Section5"
Object.Height = 360
NumControls = 0
EndProperty
End
Attribute VB_Name = "Dareportbmyszxxx"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub DataReport_Initialize()
Dim AdoCon As New ADODB.Connection
'定义临时变量zjsxje,用于存储该部门在该预算科目的资金上限
Dim zjsxje As Double
'定义临时变量ywjezh,用于存储该部门在该预算科目的预算金额总和
Dim ywjezh As Double
'定义临时变量wcbl,用于存储该部门在该预算科目的资金完成比例
Dim wcbl As Double
'定义临时变量cysje,用于存储该部门在该预算科目的超预算金额
Dim cysje As Double
Dim str1 As String
Const iW = 3 '缇,误差调整
Printer.PaperSize = 9
'定义该报表的报表宽度
Dareportbmyszxxx.ReportWidth = Printer.Width - Dareportbmyszxxx.LeftMargin - Dareportbmyszxxx.RightMargin - iW
Dim AdoRec As New ADODB.Recordset
Dim AdoRec1 As New ADODB.Recordset
Dim txt As New Collection
Dim ctl As Object
Dim ctl1 As Object
'连接数据库
AdoCon.Open nowconnectstring
'设置并执行SQL语句,返回报表所需的数据,作为报表的数据源
str1 = "SELECT a1, a2, a3, SUM(a4) AS b1, SUM(a5) AS b2, SUM(a4)-a3 AS b3 FROM Vbmyszxxx where a7>='" & starttime & "' and a7<='" & endtime & "' and a8='" & m_gsbmmc & "' GROUP BY a1, a2, a3"
AdoRec.Open str1, AdoCon
'设置该报表的数据源
Set Dareportbmyszxxx.DataSource = AdoRec
'设置并执行SQL语句,返回该报表用到的该部门在该预算科目上的的
'资金上限、预算金额总、资金完成比例和超预算金额
str1 = "SELECT a1, a2, a3, SUM(a4) AS b1, SUM(a5) AS b2, Sum(a4)-a3 AS b3 FROM Vbmyszxxx where a7>='" & starttime & "' and a7<='" & endtime & "' and a8='" & m_gsbmmc & "' GROUP BY a1, a2, a3"
AdoRec1.Open str1, AdoCon
'在报表上显示部门名称和报表的起始时间、截止时间
For Each ctl1 In Me.Sections.Item("Section2").Controls
If TypeName(ctl1) = "RptLabel" Then
Select Case ctl1.Name
Case "Label20"
ctl1.Caption = "部门:" & m_gsbmmc
Case "Label21"
ctl1.Caption = "起始时间:" & starttime
Case "Label23"
ctl1.Caption = "截至时间:" & endtime
End Select
End If
Next
'计算该报表用到的该部门在该预算科目上的的
'资金上限、预算金额总、资金完成比例和超预算金额
zjsxje = 0
ywjezh = 0
wcbl = 0
cysje = 0
Do While Not AdoRec1.EOF
zjsxje = zjsxje + AdoRec1.Fields("a3")
ywjezh = ywjezh + AdoRec1.Fields("b1")
wcbl = wcbl + AdoRec1.Fields("b2")
cysje = cysje + AdoRec1.Fields("b3")
AdoRec1.MoveNext
Loop
'在该报表中显示该部门在该预算科目上的的
'资金上限、预算金额总、资金完成比例和超预算金额
For Each ctl1 In Me.Sections.Item("Section3").Controls
If TypeName(ctl1) = "RptLabel" Then
Select Case ctl1.Name
Case "Labela3"
ctl1.Caption = Format(zjsxje, "#,##0.00")
Case "Labela4"
ctl1.Caption = Format(ywjezh, "#,##0.00")
Case "Labela5"
ctl1.Caption = Format(wcbl, "#,##0.00")
Case "Labela6"
ctl1.Caption = Format(cysje, "#,##0.00")
End Select
End If
Next
'动态设置报表中各数据控件的绑定字段
For Each ctl In Me.Sections.Item("Section1").Controls
If TypeName(ctl) = "RptTextBox" Then
Select Case ctl.Name
Case "Text1"
ctl.DataField = AdoRec.Fields("a1").Name
Case "Text2"
ctl.DataField = AdoRec.Fields("a2").Name
Case "Text3"
ctl.DataField = AdoRec.Fields("a3").Name
Case "Text4"
ctl.DataField = AdoRec.Fields("b1").Name
Case "Text5"
ctl.DataField = AdoRec.Fields("b2").Name
Case "Text6"
ctl.DataField = AdoRec.Fields("b3").Name
End Select
End If
Next
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -