查询打印?
查询按钮命令:
select dlhwyd
SET TALK OFF
SELECT COUNT(*) AS 车牌号 FROM dlhwyd WHERE BETWEEN(起运日期,THISFORM.TEXT1.VALUE,THISFORM.TEXT2.VALUE) AND ALLTRIM(承运人)==ALLTRIM(THISFORM.TEXT3.VALUE) INTO CURSOR TTT
SELECT TTT
THISFORM.TEXT4.VALUE=TTT.车牌号
问题?
1:在grid1里显示我查询的结果,其它记录不显示。
2:求打印按钮命令(查询结果以报表形式打印)
[解决办法]
Set Talk Off&& 此句建议放到主程序开头
*!*Select dlhwyd&& 此句多余
Select Count(*) As 车牌号 Into Cursor TTT From dlhwyd Where Between(起运日期,Thisform.TEXT1.Value,Thisform.TEXT2.Value) And Alltrim(承运人)==Alltrim(Thisform.TEXT3.Value)
*!*Select TTT&& 此句多余
Thisform.TEXT4.Value=TTT.车牌号
Thisform.Grid1.RecordSource=Null
Select * Into Cursor BBB From dlhwyd Where Between(起运日期,Thisform.TEXT1.Value,Thisform.TEXT2.Value) And Alltrim(承运人)==Alltrim(Thisform.TEXT3.Value)
Thisform.Grid1.RecordSource='BBB'
Thisform.Grid1.Refresh
打印就一句
Report Form 报表 Noconsole To Printer Prompt Preview
不过 报表 需要你自己设计
[解决办法]
*---VFP6.0 代码
*---“查询”按钮代码
SELECT COUNT(*) AS 车辆台数 FROM dlhwyd WHERE BETWEEN(起运日期,THISFORM.TEXT1.VALUE,THISFORM.TEXT2.VALUE) AND ALLTRIM(承运人)==ALLTRIM(THISFORM.TEXT3.VALUE) INTO CURSOR TTT
SELECT TTT
THISFORM.TEXT4.VALUE=TTT.车辆台数
*---问题1:在GRID1中显示符合条件的记录
SET FILTER TO OCCURS(ALLTRIM(THISFORM.TEXT3.VALUE),dlhwyd.承运人)>0
GO TOP
WITH THISFORM.GRID1
.RECORDSOURCE="dlhwyd"
.RECORDSOURCETYPE=1
.REFRESH
ENDWITH
*---问题2:“打印”按钮代码
*---先在报表设计器中设置好打印格式,保存为报表文件,假如报表文件名为REPNAME.FRX
REPORT FORM REPNAME PREVIEW NOCONSOLE FOR ALLTRIM(承运人)==ALLTRIM(THISFORM.TEXT3.VALUE) &&先预览后,再打印