VB 报表显示不了
类文件
Option Explicit
Public Sub ShowPrint(str As String) '图书查询的打印预览函数
On Error Resume Next
Dim mrc As Recordset '定义一个记录集
Dim txtsql As String
Dim msgtext As String
txtsql = str
Set mrc = New Recordset '实例一个记录集
Set mrc = ExecuteSQL(txtsql, msgtext)
'记录集的打开内容 是用户查询的内容
Dim rs_lab As Integer
Dim rs_txt As Integer
Dim num As Integer
rs_lab = 0
rs_txt = 0
'动态判断查询的内容,给报表的标签(rptlabel),文本框(rpttextbox)赋值
With DataReport1
' .DataMember = ""
Set .DataSource = mrc '设置报表的 datasource
.Hide
.DataMember = ""
With .Sections("section2").Controls '报表的页标题
For num = 1 To .Count
If TypeOf .Item(num) Is RptLabel Then
.Item(num).Caption = mrc.Fields(rs_lab + 1).Name & ":"
rs_lab = rs_lab + 1
End If
Next num
End With
With .Sections("section1").Controls '报表的细节部分
For num = 1 To .Count
If TypeOf .Item(num) Is RptTextBox Then
.Item(num).DataMember = ""
.Item(num).DataField = mrc(rs_txt).Name
rs_txt = rs_txt + 1
End If
Next num
End With
.Refresh
.Show
End With
End Sub
程序文件调用一个showprint(“select *from Customers”)
报表中的数据显示不了。
问题点数:10、回复次数:1Top
1 楼ejoe313(做最好的自己!)回复于 2005-08-22 17:36:37 得分 10
定义为 Function
然后调用showprint(“select *from Customers”)Top




