📄 mdlreport
字号:
For i = 0 To UBound(RptExcursus)
If i > 10 Then Exit For
With .PageHeader
StrName = "LabelExcursus" & Trim(Str(i + 1))
.Controls(StrName).Visible = True
.Controls(StrName) = RptExcursus(i)
End With
Next i
IntLeft = 0
If (Not RstDetail.EOF) And (Not RstDetail.BOF) Then
For i = 1 To RstDetail.Fields.Count
If i = 1 Then
'根据数值宽度凋整报表列宽
If Len(RstDetail.Fields(i - 1).Value) < 4 Then
intWidth = (Len(RstDetail.Fields(i - 1).Value) + 1) * WidthMultiple
Else
intWidth = Len(RstDetail.Fields(i - 1).Value) * WidthMultiple
End If
NumWidth = RstSize.RecordCount
NumWidth = Int((.Width - intWidth) / NumWidth)
TextCount = TextCount + 1
StrField = RstDetail.Fields(i - 1).name
BlnIsHave = True
Else
'提取报表单列标题
If (Not RstSize.EOF) And (Not RstSize.BOF) Then
NumberCount = NumberCount + 1
intWidth = NumWidth
StrCaption = RstSize![Description]
StrField = RstSize![ID]
StrName = "Label" & Trim(Str(NumberCount + TextCount))
.PageHeader.Controls(StrName).Caption = StrCaption
BlnIsHave = True
RstSize.MoveNext
End If
End If
If BlnIsHave Then
'初始化报表标题
With .PageHeader
StrName = "Label" & Trim(Str(NumberCount + TextCount))
.Controls(StrName).Visible = True
'.Controls(StrName).Caption = strCaption
.Controls(StrName).Left = IntLeft
.Controls(StrName).Width = intWidth
End With
'初始化报表细目
With .Detail
StrName = "Field" & Trim(Str(NumberCount + TextCount))
.Controls(StrName).Visible = True
.Controls(StrName).DataField = StrField
.Controls(StrName).Left = IntLeft
.Controls(StrName).Width = intWidth
.Controls(StrName).OutputFormat = ("##,##0;-##,##0; ;")
End With
'递增变量 IntLeft 用来调整 Left 属性
IntLeft = IntLeft + intWidth
End If
BlnIsHave = False
Next i
End If
With .LineHead
.x1 = IntLeft
.x2 = IntLeft
End With
With .LineVertical
.x1 = IntLeft
.x2 = IntLeft
.Y1 = 0
.Y2 = 250 * RstDetail.RecordCount
End With
With .LineHorizontal
.x1 = 0
.x2 = IntLeft
End With
'读取公司信息(名称,地址,电话,传真,Email)
Set RstCorp = New ADODB.Recordset
StrSqlCorp = "SELECT mis_Customer.ContactNum AS CorpID, mis_Customer.ContactName AS CorpName," & _
"Mis_City.captal, Mis_City.city, mis_Customer.Phone, mis_Customer.Fax, mis_Customer.Email, Mis_City.tel" & _
" " & "FROM mis_Customer INNER JOIN AccountName ON mis_Customer.ContactNum = AccountName.WrokCenter INNER JOIN" & _
" " & "Mis_City ON mis_Customer.City = Mis_City.City_ID" & _
" " & "WHERE AccountName.AccountID='" & Trim(strAccountName) & "'"
RstCorp.Open StrSqlCorp, GetCNClient, adOpenKeyset, adLockOptimistic
'初始化报表尾之公司信息
If RstCorp.RecordCount > 0 Then
RstCorp.MoveFirst
.LabelFoot8 = RstCorp.Fields("CorpName")
.LabelFoot10 = RstCorp.Fields("Captal") & RstCorp.Fields("city")
.LabelFoot12 = "(" & RstCorp.Fields("Tel") & ")-" & RstCorp.Fields("Phone")
.LabelFoot14 = RstCorp.Fields("Fax")
.LabelFoot16 = RstCorp.Fields("Email")
Else
End If
.Show 1
End With
'善后处理
RstEviName.Close
RstDetail.Close
RstSize.Close
RstCorp.Close
Set RstDetail = Nothing
Set RstSize = Nothing
Set RstCorp = Nothing
Set RstEviName = Nothing
Set Rpt = Nothing
Exit Sub
Err_Report:
mis_HandError Err.Number, "GInitReport"
End Sub
Public Sub ReportParent(ByVal StrSql As String, RptHead As String, RptCaption() As Variant)
''On error goto Err_Report
Const WidthMultiple = 200, WidthScale = 2
Dim RstRpt, RstCorp As ADODB.Recordset
Dim Rpt As RptParent
Dim i, intWidth, IntLeft, NumWidth As Integer
Dim StrField, StrCaption, StrName As String
Dim StrSqlCorp As String
Set RstRpt = New ADODB.Recordset
Set Rpt = New RptParent
RstRpt.Open StrSql, GetCNClient, adOpenKeyset, adLockOptimistic
If RstRpt.RecordCount > 0 Then RstRpt.MoveFirst
IntLeft = 0
With Rpt
.DataControl1.Recordset = RstRpt
.LabelHead.Caption = RptHead
.LabelHead.Width = Len(RptHead) * WidthMultiple * WidthScale
.LabelHead.Left = (.Width - .LabelHead.Width) / 2
If (Not RstRpt.EOF) And (Not RstRpt.BOF) Then
For i = 1 To RstRpt.Fields.Count
If IsNumeric(RstRpt.Fields(i - 1).Value) Then
'根据数值宽度凋整报表列宽
If Len(RstRpt.Fields(i - 1).Value) <= 2 Then
intWidth = (2 + Len(RstRpt.Fields(i - 1).Value)) * WidthMultiple
Else
intWidth = Len(RstRpt.Fields(i - 1).Value) * WidthMultiple
End If
Else
'根据数值宽度凋整报表列宽
If Len(RstRpt.Fields(i - 1).Value) <= 4 Then
intWidth = (Len(RstRpt.Fields(i - 1).Value) + 1) * WidthMultiple
Else
intWidth = Len(RstRpt.Fields(i - 1).Value) * WidthMultiple
End If
End If
'提取报表单列标题
If IsNumeric(RptCaption(i - 1)) Then
StrCaption = LoadResString(Val(RptCaption(i - 1) & GLanguageID))
Else
StrCaption = RptCaption(i - 1)
End If
With .PageHeader
StrName = "Label" & Trim(Str(i))
.Controls(StrName).Visible = True
.Controls(StrName).Caption = StrCaption
.Controls(StrName).Left = IntLeft
.Controls(StrName).Width = intWidth
End With
StrField = RstRpt.Fields(i - 1).name
With .Detail
StrName = "Field" & Trim(Str(i))
.Controls(StrName).Visible = True
.Controls(StrName).DataField = StrField
.Controls(StrName).Left = IntLeft
.Controls(StrName).Width = intWidth
.Controls(StrName).OutputFormat = ("##,##0;-##,##0; ;")
End With
With .PageFooter
StrName = "FieldSum" & Trim(Str(i))
.Controls(StrName).Visible = True
.Controls(StrName).DataField = StrField
.Controls(StrName).Left = IntLeft
.Controls(StrName).Width = intWidth
.Controls(StrName).OutputFormat = ("##,##0;-##,##0; ;")
End With
IntLeft = IntLeft + intWidth
Next i
End If
With .LineHead
.x1 = IntLeft
.x2 = IntLeft
End With
With .LineVertical
.x1 = IntLeft
.x2 = IntLeft
.Y1 = 0
.Y2 = 250 * RstRpt.RecordCount
End With
With .LineHorizontal
.x1 = 0
.x2 = IntLeft
End With
'读取公司信息(名称,地址,电话,传真,Email)
Set RstCorp = New ADODB.Recordset
StrSqlCorp = "SELECT mis_Customer.ContactNum AS CorpID, mis_Customer.ContactName AS CorpName," & _
"Mis_City.captal, Mis_City.city, mis_Customer.Phone, mis_Customer.Fax, mis_Customer.Email, Mis_City.tel" & _
" " & "FROM mis_Customer INNER JOIN AccountName ON mis_Customer.ContactNum = AccountName.WrokCenter INNER JOIN" & _
" " & "Mis_City ON mis_Customer.City = Mis_City.City_ID" & _
" " & "WHERE AccountName.AccountID='" & Trim(strAccountName) & "'"
RstCorp.Open StrSqlCorp, GetCNClient, adOpenKeyset, adLockOptimistic
'初始化报表尾之公司信息
If RstCorp.RecordCount > 0 Then
RstCorp.MoveFirst
.LabelFoot8 = RstCorp.Fields("CorpName")
.LabelFoot10 = RstCorp.Fields("Captal") & RstCorp.Fields("city")
.LabelFoot12 = "(" & RstCorp.Fields("Tel") & ")-" & RstCorp.Fields("Phone")
.LabelFoot14 = RstCorp.Fields("Fax")
.LabelFoot16 = RstCorp.Fields("Email")
Else
End If
'显示报表
.Show 1
End With
'善后处理
RstRpt.Close
RstCorp.Close
Set RstRpt = Nothing
Set RstCorp = Nothing
Set Rpt = Nothing
Exit Sub
Err_Report:
mis_HandError Err.Number, "GInitReport"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -