📄 datareport1.dsr
字号:
VERSION 5.00
Begin {78E93846-85FD-11D0-8487-00A0C90DC8A9} DataReport1
Caption = "DataReport1"
ClientHeight = 11010
ClientLeft = 60
ClientTop = 450
ClientWidth = 15240
StartUpPosition = 3 'Windows Default
_ExtentX = 26882
_ExtentY = 19420
_Version = 393216
_DesignerVersion= 100684101
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
GridX = 1
GridY = 1
LeftMargin = 1440
RightMargin = 1440
TopMargin = 1440
BottomMargin = 1440
NumSections = 5
SectionCode0 = 1
BeginProperty Section0 {1C13A8E0-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Section4"
Object.Height = 330
NumControls = 0
EndProperty
SectionCode1 = 2
BeginProperty Section1 {1C13A8E0-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Section2"
Object.Height = 360
NumControls = 0
EndProperty
SectionCode2 = 4
BeginProperty Section2 {1C13A8E0-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Section1"
Object.Height = 1440
NumControls = 4
ItemType0 = 4
BeginProperty Item0 {1C13A8E2-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Text1"
Object.Left = 567
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
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
ItemType1 = 4
BeginProperty Item1 {1C13A8E2-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Text2"
Object.Left = 2268
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
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
ItemType2 = 4
BeginProperty Item2 {1C13A8E2-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Text3"
Object.Left = 3969
Object.Width = 1133
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
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
ItemType3 = 4
BeginProperty Item3 {1C13A8E2-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Text4"
Object.Left = 5669
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
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
EndProperty
SectionCode3 = 7
BeginProperty Section3 {1C13A8E0-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Section3"
Object.Height = 360
NumControls = 0
EndProperty
SectionCode4 = 8
BeginProperty Section4 {1C13A8E0-A0B6-11D0-848E-00A0C90DC8A9}
_Version = 393216
Name = "Section5"
Object.Height = 360
NumControls = 0
EndProperty
End
Attribute VB_Name = "DataReport1"
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 AdoRec As New ADODB.Recordset
Dim txt As New Collection
Dim ctl As Object
Dim strconnect As String
Dim getfield As String
' Dim strsql As String
strconnect = "Provider=Microsoft.Jet.OLEDB.4.0;Persist " & _
"Security Info=False;Data Source=" & App.Path & "\db.mdb"
AdoCon.ConnectionString = strconnect
AdoCon.Open
'查询数据库,可以改动sql语句strsql
AdoRec.Open strsql, AdoCon, adOpenDynamic, adLockOptimistic
'设置报表的数据源
Set DataReport1.DataSource = AdoRec
For Each ctl In Me.Sections.Item("Section1").Controls
If TypeName(ctl) = "RptTextBox" Then
Select Case ctl.Name
Case "Text1"
getfield = "datetime"
ctl.DataField = AdoRec.Fields(getfield).Name
Case "Text2"
ctl.DataField = AdoRec.Fields("vehicleID").Name
Case "Text3"
ctl.DataField = AdoRec.Fields("speed").Name
Case "Text4"
ctl.DataField = AdoRec.Fields("roadName").Name
End Select
End If
Next
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -