该拖动的都试过了;使用表尾明显不行,因为当记录太少时表尾会往上移。可能是我划线的原因吧,但明明没错啊Dim cnn As Connection Set cnn = New Connection strSQL = "Provider=SQLOLEDB.1;Password=llztclking;Persist Security Info=True;User ID=sa;Initial Catalog=jxda;Data Source=LUCKII" cnn.CursorLocation = adUseClient cnn.Open strSQL adoRecordsetX.Open "Select * from S_CTVRB", cnn, adOpenDynamic, adLockBatchOptimistic Set rptS_CTVRB.DataSource = adoRecordsetX Dim DSec1_Txt_Collection As New Collection Dim DSec1_Lbl_Collection As New Collection Dim DSec1_Shp_Collection As New Collection Dim PSec3_Line_Collection As New Collection Dim PSec3_HLine_Collection As New Collection Dim PSec3_VLine_Collection As New Collection Dim PSec3_Lbl_Collection As New Collection Dim PSec3_Shp_Collection As New Collection Dim Ctl As Object Dim i As Integer '----------------------建collection For Each Ctl In Me.Sections.Item("Section1").Controls '细节Section1 Select Case TypeName(Ctl) Case "RptLabel" DSec1_Lbl_Collection.Add Ctl Case "RptShape" DSec1_Shp_Collection.Add Ctl Case "RptTextBox" Ctl.DataField = adoRecordsetX.Fields.Item(0).Name '先将所有TextBox(RptTextBox) 控件绑定到某一字段,否则报错! DSec1_Txt_Collection.Add Ctl End Select ' Ctl.Visible = False Next Ctl ''--------------DSec1_Lbl_Collection序号 'For i = 1 To adoRecordsetX.RecordCount ' DSec1_Lbl_Collection.Item(i).Caption = str(i) 'Next i On Error Resume Next For Each Ctl In Me.Sections.Item("Section3").Controls Select Case TypeName(Ctl) Case "RptLabel" PSec3_Lbl_Collection.Add Ctl Case "RptShape" PSec3_Shp_Collection.Add Ctl Case "RptLine" PSec3_Line_Collection.Add Ctl If Ctl.Height = 0 Then PSec3_HLine_Collection.Add Ctl Else PSec3_VLine_Collection.Add Ctl End If End Select ' Ctl.Visible = False Next Ctl '-----------------------------------划竖线 Dim otherH As Integer Dim h As Integer Dim ss As Integer ss = 1 otherH = Me.Sections("section2").Height + Me.Sections("section3").Height + Me.Sections("section4").Height + Me.Sections("section5").Height h = 11907 - Me.TopMargin - Me.BottomMargin - otherH shapeH = Me.Sections("section1").Controls("Shape1").Height If adoRecordsetX.RecordCount >= (h / shapeH) Then For i = 1 To PSec3_Line_Collection.Count PSec3_Line_Collection.Item(i).Visible = False Next i Else For i = 1 To (h - shapeH * (adoRecordsetX.RecordCount)) / shapeH '- 1 PSec3_HLine_Collection.Item(i).top = i * shapeH ' MsgBox PSec3_HLine_Collection.Item(i).top Next i ss = i - 1 For i = 1 To PSec3_VLine_Collection.Count PSec3_VLine_Collection.Item(i).Height = ss * shapeH Next i For i = 1 To PSec3_Lbl_Collection.Count PSec3_Lbl_Collection.Item(i).top = ss * shapeH + PSec3_Lbl_Collection.Item(i).top ' + (h - shapeH * (adoRecordsetX.RecordCount)) Next i For i = 1 To PSec3_Shp_Collection.Count PSec3_Shp_Collection.Item(i).top = ss * shapeH + PSec3_Shp_Collection.Item(i).top '+ (h - shapeH * (adoRecordsetX.RecordCount)) Next i End If 请指教
该拖动的都试过了;使用表尾明显不行,因为当记录太少时表尾会往上移。可能是我划线的原因吧,但明明没错啊Dim cnn As Connection Set cnn = New Connection strSQL = "Provider=SQLOLEDB.1;Password=llztclking;Persist Security Info=True;User ID=sa;Initial Catalog=jxda;Data Source=LUCKII" cnn.CursorLocation = adUseClient cnn.Open strSQL adoRecordsetX.Open "Select * from S_CTVRB", cnn, adOpenDynamic, adLockBatchOptimistic Set rptS_CTVRB.DataSource = adoRecordsetX Dim DSec1_Txt_Collection As New Collection Dim DSec1_Lbl_Collection As New Collection Dim DSec1_Shp_Collection As New Collection Dim PSec3_Line_Collection As New Collection Dim PSec3_HLine_Collection As New Collection Dim PSec3_VLine_Collection As New Collection Dim PSec3_Lbl_Collection As New Collection Dim PSec3_Shp_Collection As New Collection Dim Ctl As Object Dim i As Integer '----------------------建collection For Each Ctl In Me.Sections.Item("Section1").Controls '细节Section1 Select Case TypeName(Ctl) Case "RptLabel" DSec1_Lbl_Collection.Add Ctl Case "RptShape" DSec1_Shp_Collection.Add Ctl Case "RptTextBox" Ctl.DataField = adoRecordsetX.Fields.Item(0).Name '先将所有TextBox(RptTextBox) 控件绑定到某一字段,否则报错! DSec1_Txt_Collection.Add Ctl End Select ' Ctl.Visible = False Next Ctl ''--------------DSec1_Lbl_Collection序号 'For i = 1 To adoRecordsetX.RecordCount ' DSec1_Lbl_Collection.Item(i).Caption = str(i) 'Next i On Error Resume Next For Each Ctl In Me.Sections.Item("Section3").Controls Select Case TypeName(Ctl) Case "RptLabel" PSec3_Lbl_Collection.Add Ctl Case "RptShape" PSec3_Shp_Collection.Add Ctl Case "RptLine" PSec3_Line_Collection.Add Ctl If Ctl.Height = 0 Then PSec3_HLine_Collection.Add Ctl Else PSec3_VLine_Collection.Add Ctl End If End Select ' Ctl.Visible = False Next Ctl '-----------------------------------划竖线 Dim otherH As Integer Dim h As Integer Dim ss As Integer ss = 1 otherH = Me.Sections("section2").Height + Me.Sections("section3").Height + Me.Sections("section4").Height + Me.Sections("section5").Height h = 11907 - Me.TopMargin - Me.BottomMargin - otherH shapeH = Me.Sections("section1").Controls("Shape1").Height If adoRecordsetX.RecordCount >= (h / shapeH) Then For i = 1 To PSec3_Line_Collection.Count PSec3_Line_Collection.Item(i).Visible = False Next i Else For i = 1 To (h - shapeH * (adoRecordsetX.RecordCount)) / shapeH '- 1 PSec3_HLine_Collection.Item(i).top = i * shapeH ' MsgBox PSec3_HLine_Collection.Item(i).top Next i ss = i - 1 For i = 1 To PSec3_VLine_Collection.Count PSec3_VLine_Collection.Item(i).Height = ss * shapeH Next i For i = 1 To PSec3_Lbl_Collection.Count PSec3_Lbl_Collection.Item(i).top = ss * shapeH + PSec3_Lbl_Collection.Item(i).top ' + (h - shapeH * (adoRecordsetX.RecordCount)) Next i For i = 1 To PSec3_Shp_Collection.Count PSec3_Shp_Collection.Item(i).top = ss * shapeH + PSec3_Shp_Collection.Item(i).top '+ (h - shapeH * (adoRecordsetX.RecordCount)) Next i End If 请指教
谢谢
http://go8.163.com/dbcontrols/
上有个INTOCELL控件可以实现.
Set cnn = New Connection
strSQL = "Provider=SQLOLEDB.1;Password=llztclking;Persist Security Info=True;User ID=sa;Initial Catalog=jxda;Data Source=LUCKII"
cnn.CursorLocation = adUseClient
cnn.Open strSQL
adoRecordsetX.Open "Select * from S_CTVRB", cnn, adOpenDynamic, adLockBatchOptimistic
Set rptS_CTVRB.DataSource = adoRecordsetX
Dim DSec1_Txt_Collection As New Collection
Dim DSec1_Lbl_Collection As New Collection
Dim DSec1_Shp_Collection As New Collection
Dim PSec3_Line_Collection As New Collection
Dim PSec3_HLine_Collection As New Collection
Dim PSec3_VLine_Collection As New Collection
Dim PSec3_Lbl_Collection As New Collection
Dim PSec3_Shp_Collection As New Collection
Dim Ctl As Object
Dim i As Integer
'----------------------建collection
For Each Ctl In Me.Sections.Item("Section1").Controls '细节Section1
Select Case TypeName(Ctl)
Case "RptLabel"
DSec1_Lbl_Collection.Add Ctl
Case "RptShape"
DSec1_Shp_Collection.Add Ctl
Case "RptTextBox"
Ctl.DataField = adoRecordsetX.Fields.Item(0).Name
'先将所有TextBox(RptTextBox) 控件绑定到某一字段,否则报错!
DSec1_Txt_Collection.Add Ctl
End Select
' Ctl.Visible = False
Next Ctl
''--------------DSec1_Lbl_Collection序号
'For i = 1 To adoRecordsetX.RecordCount
' DSec1_Lbl_Collection.Item(i).Caption = str(i)
'Next i
On Error Resume Next
For Each Ctl In Me.Sections.Item("Section3").Controls
Select Case TypeName(Ctl)
Case "RptLabel"
PSec3_Lbl_Collection.Add Ctl
Case "RptShape"
PSec3_Shp_Collection.Add Ctl
Case "RptLine"
PSec3_Line_Collection.Add Ctl
If Ctl.Height = 0 Then
PSec3_HLine_Collection.Add Ctl
Else
PSec3_VLine_Collection.Add Ctl
End If
End Select
' Ctl.Visible = False
Next Ctl
'-----------------------------------划竖线
Dim otherH As Integer
Dim h As Integer
Dim ss As Integer
ss = 1
otherH = Me.Sections("section2").Height + Me.Sections("section3").Height + Me.Sections("section4").Height + Me.Sections("section5").Height
h = 11907 - Me.TopMargin - Me.BottomMargin - otherH
shapeH = Me.Sections("section1").Controls("Shape1").Height
If adoRecordsetX.RecordCount >= (h / shapeH) Then
For i = 1 To PSec3_Line_Collection.Count
PSec3_Line_Collection.Item(i).Visible = False
Next i
Else
For i = 1 To (h - shapeH * (adoRecordsetX.RecordCount)) / shapeH '- 1
PSec3_HLine_Collection.Item(i).top = i * shapeH
' MsgBox PSec3_HLine_Collection.Item(i).top
Next i
ss = i - 1
For i = 1 To PSec3_VLine_Collection.Count
PSec3_VLine_Collection.Item(i).Height = ss * shapeH
Next i
For i = 1 To PSec3_Lbl_Collection.Count
PSec3_Lbl_Collection.Item(i).top = ss * shapeH + PSec3_Lbl_Collection.Item(i).top ' + (h - shapeH * (adoRecordsetX.RecordCount))
Next i
For i = 1 To PSec3_Shp_Collection.Count
PSec3_Shp_Collection.Item(i).top = ss * shapeH + PSec3_Shp_Collection.Item(i).top '+ (h - shapeH * (adoRecordsetX.RecordCount))
Next i
End If
请指教
Set cnn = New Connection
strSQL = "Provider=SQLOLEDB.1;Password=llztclking;Persist Security Info=True;User ID=sa;Initial Catalog=jxda;Data Source=LUCKII"
cnn.CursorLocation = adUseClient
cnn.Open strSQL
adoRecordsetX.Open "Select * from S_CTVRB", cnn, adOpenDynamic, adLockBatchOptimistic
Set rptS_CTVRB.DataSource = adoRecordsetX
Dim DSec1_Txt_Collection As New Collection
Dim DSec1_Lbl_Collection As New Collection
Dim DSec1_Shp_Collection As New Collection
Dim PSec3_Line_Collection As New Collection
Dim PSec3_HLine_Collection As New Collection
Dim PSec3_VLine_Collection As New Collection
Dim PSec3_Lbl_Collection As New Collection
Dim PSec3_Shp_Collection As New Collection
Dim Ctl As Object
Dim i As Integer
'----------------------建collection
For Each Ctl In Me.Sections.Item("Section1").Controls '细节Section1
Select Case TypeName(Ctl)
Case "RptLabel"
DSec1_Lbl_Collection.Add Ctl
Case "RptShape"
DSec1_Shp_Collection.Add Ctl
Case "RptTextBox"
Ctl.DataField = adoRecordsetX.Fields.Item(0).Name
'先将所有TextBox(RptTextBox) 控件绑定到某一字段,否则报错!
DSec1_Txt_Collection.Add Ctl
End Select
' Ctl.Visible = False
Next Ctl
''--------------DSec1_Lbl_Collection序号
'For i = 1 To adoRecordsetX.RecordCount
' DSec1_Lbl_Collection.Item(i).Caption = str(i)
'Next i
On Error Resume Next
For Each Ctl In Me.Sections.Item("Section3").Controls
Select Case TypeName(Ctl)
Case "RptLabel"
PSec3_Lbl_Collection.Add Ctl
Case "RptShape"
PSec3_Shp_Collection.Add Ctl
Case "RptLine"
PSec3_Line_Collection.Add Ctl
If Ctl.Height = 0 Then
PSec3_HLine_Collection.Add Ctl
Else
PSec3_VLine_Collection.Add Ctl
End If
End Select
' Ctl.Visible = False
Next Ctl
'-----------------------------------划竖线
Dim otherH As Integer
Dim h As Integer
Dim ss As Integer
ss = 1
otherH = Me.Sections("section2").Height + Me.Sections("section3").Height + Me.Sections("section4").Height + Me.Sections("section5").Height
h = 11907 - Me.TopMargin - Me.BottomMargin - otherH
shapeH = Me.Sections("section1").Controls("Shape1").Height
If adoRecordsetX.RecordCount >= (h / shapeH) Then
For i = 1 To PSec3_Line_Collection.Count
PSec3_Line_Collection.Item(i).Visible = False
Next i
Else
For i = 1 To (h - shapeH * (adoRecordsetX.RecordCount)) / shapeH '- 1
PSec3_HLine_Collection.Item(i).top = i * shapeH
' MsgBox PSec3_HLine_Collection.Item(i).top
Next i
ss = i - 1
For i = 1 To PSec3_VLine_Collection.Count
PSec3_VLine_Collection.Item(i).Height = ss * shapeH
Next i
For i = 1 To PSec3_Lbl_Collection.Count
PSec3_Lbl_Collection.Item(i).top = ss * shapeH + PSec3_Lbl_Collection.Item(i).top ' + (h - shapeH * (adoRecordsetX.RecordCount))
Next i
For i = 1 To PSec3_Shp_Collection.Count
PSec3_Shp_Collection.Item(i).top = ss * shapeH + PSec3_Shp_Collection.Item(i).top '+ (h - shapeH * (adoRecordsetX.RecordCount))
Next i
End If
请指教
http://go8.163.com/dbcontrols
有个报表的源代码你参考一下.
报表都是先画好然后改变查询条件即可.
是163的问题.
[email protected]我要有关报表的东西
感激不尽