⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dareportwwg.dsr

📁 VB数据库设计的代码。需要根据自己的数据库再作调整
💻 DSR
📖 第 1 页 / 共 2 页
字号:
            Format          =   "#,##0.00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   1
         EndProperty
      EndProperty
      ItemType2       =   4
      BeginProperty Item2 {1C13A8E2-A0B6-11D0-848E-00A0C90DC8A9} 
         _Version        =   393216
         Name            =   "Text4"
         Object.Left            =   5669
         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            =   7370
         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            =   1134
         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            =   9071
         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            =   1134
         Object.Height          =   555
      EndProperty
      ItemType7       =   5
      BeginProperty Item7 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9} 
         _Version        =   393216
         Name            =   "Line16"
         Object.Left            =   9071
         Object.Height          =   555
      EndProperty
      ItemType8       =   5
      BeginProperty Item8 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9} 
         _Version        =   393216
         Name            =   "Line17"
         Object.Left            =   7370
         Object.Height          =   555
      EndProperty
      ItemType9       =   5
      BeginProperty Item9 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9} 
         _Version        =   393216
         Name            =   "Line18"
         Object.Left            =   5669
         Object.Height          =   555
      EndProperty
      ItemType10      =   5
      BeginProperty Item10 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9} 
         _Version        =   393216
         Name            =   "Line19"
         Object.Left            =   3969
         Object.Height          =   555
      EndProperty
      ItemType11      =   5
      BeginProperty Item11 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9} 
         _Version        =   393216
         Name            =   "Line20"
         Object.Left            =   2835
         Object.Height          =   555
      EndProperty
      ItemType12      =   5
      BeginProperty Item12 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9} 
         _Version        =   393216
         Name            =   "Line3"
         Object.Left            =   1134
         Object.Top             =   567
         Object.Width           =   9071
      EndProperty
      ItemType13      =   5
      BeginProperty Item13 {1C13A8E3-A0B6-11D0-848E-00A0C90DC8A9} 
         _Version        =   393216
         Name            =   "Line10"
         Object.Left            =   10205
         Object.Height          =   555
      EndProperty
   EndProperty
   SectionCode3    =   7
   BeginProperty Section3 {1C13A8E0-A0B6-11D0-848E-00A0C90DC8A9} 
      _Version        =   393216
      Name            =   "Section3"
      Object.Height          =   570
      KeepTogether    =   -1  'True
      NumControls     =   5
      ItemType0       =   3
      BeginProperty Item0 {1C13A8E1-A0B6-11D0-848E-00A0C90DC8A9} 
         _Version        =   393216
         Name            =   "Label8"
         Object.Left            =   1134
         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            =   3968
         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            =   5669
         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            =   7370
         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
      ItemType4       =   3
      BeginProperty Item4 {1C13A8E1-A0B6-11D0-848E-00A0C90DC8A9} 
         _Version        =   393216
         Name            =   "Labela6"
         Object.Left            =   9071
         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
   EndProperty
   SectionCode4    =   8
   BeginProperty Section4 {1C13A8E0-A0B6-11D0-848E-00A0C90DC8A9} 
      _Version        =   393216
      Name            =   "Section5"
      Object.Height          =   354
      NumControls     =   0
   EndProperty
End
Attribute VB_Name = "Dareportyszxzb"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub DataReport_Initialize()
Dim AdoCon As New ADODB.Connection
Dim str1 As String
Dim zjsxje As Double
    Dim ywjezh As Double
    Dim wcbl As Double
    Dim cysje As Double
    Const iW = 3 '缇,误差调整
    Printer.PaperSize = 9
    Dareportyszxzb.ReportWidth = Printer.Width - Dareportyszxzb.LeftMargin - Dareportyszxzb.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 "Provider=SQLOLEDB.1;Password=db0822;Persist Security Info=True;User ID=sa;Initial Catalog=htgl;Data Source=JX"
   AdoCon.Open nowconnectstring
  ' AdoRec.Open "SELECT a1, a2, a3, SUM(a4) AS b1, SUM(a5) AS b2, SUM(a6) AS b3 FROM Vyszxzb where a7>='" & starttime & "' and a7<='" & endtime & "' GROUP BY a1, a2, a3", AdoCon
   AdoRec.Open "SELECT a1, a2, a3, SUM(a4) AS b1, SUM(a5) AS b2, SUM(a4)-a3 AS b3 FROM Vyszxzb where a7>='" & starttime & "' and a7<='" & endtime & "' GROUP BY a1, a2, a3", AdoCon
  ' str1 = "SELECT a1, a2, a3, SUM(a4) AS b1, SUM(a5) AS b2, SUM(a6) AS b3 FROM Vyszxzb where a7>='" & starttime & "' and a7<='" & endtime & "' GROUP BY a1, a2, a3"
   str1 = "SELECT a1, a2, a3, SUM(a4) AS b1, SUM(a5) AS b2, SUM(a4)-a3 AS b3 FROM Vyszxzb where a7>='" & starttime & "' and a7<='" & endtime & "' GROUP BY a1, a2, a3"
   AdoRec1.Open str1, AdoCon
   Set Dareportyszxzb.DataSource = AdoRec
    For Each ctl1 In Me.Sections.Item("Section2").Controls
     If TypeName(ctl1) = "RptLabel" Then
      Select Case ctl1.Name
        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 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
    
    'If Not AdoRec1.EOF Then
     For Each ctl1 In Me.Sections.Item("Section3").Controls
     If TypeName(ctl1) = "RptLabel" Then
      Select Case ctl1.Name
        Case "Labela3"
          'ctl1.Caption = str(zjsxje)
          ctl1.Caption = Format(zjsxje, "#,##0.00")
         ' AA = str(0)
          
        Case "Labela4"
          'ctl1.Caption = str(ywjezh)
          ctl1.Caption = Format(ywjezh, "#,##0.00")
        Case "Labela5"
          'ctl1.Caption = str(wcbl)
          ctl1.Caption = Format(wcbl, "#,##0.00")
        Case "Labela6"
          'ctl1.Caption = str(cysje)
          ctl1.Caption = Format(cysje, "#,##0.00")
      End Select
     End If
    Next
   ' End If
    
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -