用水晶报表有一个nodata事件
private sub report_nodata(pcancel as boolean)
dim response as integer
response=msgbox("no data!" & vbnewline & "do you still want to display the_ report",vbyesno,"no data")
if response=vbyes then
pcancel=false
else
pcancel=true
endif
end sub
这是一段源代码自己看下就明白了:
Private Sub Cmd_Jiansuo_Click()
SqlStr = "tab_client"
SqlStr = "select * from " + SqlStr '+ "where rq between" + Text1.Text + " and " + Text2.Text
Set rst = ExecuteSQL(SqlStr, Message) 'ExecuteSQL()是我写的一个处理查询语句的一个函数。
If rst.RecordCount <> 0 Then ‘在此设定将来是否显示报表
CanShow = True
Else
CanShow = False
End If
End Sub
Private Sub Cmd_Rp_Click()
Set Reports = Nothing
Set Reports = CrystalReport0 '在此作第一项的限制,以下雷同
If CanShow Then ’根据设定决定是否显示报表
Reports.Database.SetDataSource rst
Form_Rv.CRV.ReportSource = Reports
Form_Rv.Show
Form_Rv.Refresh
Else
Sta.Panels(1).Text = "目前还没有可显示的数据源."
End If
End Sub