标题:[求助]关于GRID的问题
只看楼主
santu2006
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2006-8-6
 问题点数:0 回复次数:1 
[求助]关于GRID的问题

我想让我查询出来的数据在GRID中显示出来,请看我的代码

_______________________________________________
set safety off
close tables all
select 2
use lsb1
zap
use da in 0
sqlcx = "select bh,xm,xh,bm,zw,mpn,bj,fdy from da"
bfh=0
sql1 = ".t."
if thisform.check1.value = 1
sql1 = "bh = '"+alltrim(thisform.Text1.value)+"'"
bFH = 1
endif
sql2 = ".t."
if thisform.check2.value = 1
sql2 = "xh = '"+alltrim(thisform.Text2.value)+"'"
bFH = 1
endif
sql3 = ".t."
if thisform.check3.value = 1
sql3 = "xm = '"+alltrim(thisform.Text3.value)+"'"
bFH = 1
endif
sql4 = ".t."
if thisform.check4.value = 1
sql4 = "bm = '"+alltrim(thisform.combo1.value)+"'"
bFH = 1
endif
sql5 = ".t."
if thisform.check5.value = 1
sql5 = "fdy = '"+alltrim(thisform.Text5.value)+"'"
bFH = 1
endif
sql6 = ".t."
if thisform.check6.value = 1
sql6 = "bj = '"+alltrim(thisform.Text6.value)+"'"
bFH = 1
endif
select da
go top
if bFH = 1
sqlcx = sqlcx + " where "+sql1+" and "+sql2+" and "+sql3+" and "+sql4+" and "+sql5+" and "+sql6 +" into table lsb1"
else
sqlcx = sqlcx + " into table lsb1"
endif
thisform.grid1.recordsource = "lsb1"
use
________________________________________________________

高手帮帮忙哈~

[此贴子已经被作者于2006-8-17 0:50:18编辑过]

搜索更多相关主题的帖子: GRID 
2006-08-17 00:46
Tiger5392
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:88
帖 子:2775
专家分:2237
注 册:2006-5-17
得分:0 
其实你将问题搞复杂了。第一,并不需要那么多的复选框;第二,不需要搞SELECT-SQL语句;第三,最好别在命令按钮中打开表。
(1)在FORM1.INIT()里,将表打开,并做必要的设置
CLOSE ALL
USE DA.DBF
THISFORM.GRID1.COLUMNCOUNT=-1
THISFORM.GRID1.RECORDSOURCETYPE=1
THISFORM.GRID1.RECORDSOURCE="DA"
THISFORM.TEXT1.INPUTMASK=REPLICATE("X",LEN(编号))
THISFORM.TEXT2.INPUTMASK=REPLICATE("X",LEN(学号))
THISFORM.TEXT3.INPUTMASK=REPLICATE("X",LEN(姓名))
THISFORM.TEXT4.INPUTMASK=REPLICATE("X",LEN(部门)) &&将组合框改为文本框
THISFORM.TEXT5.INPUTMASK=REPLICATE("X",LEN(辅导员))
THISFORM.TEXT6.INPUTMASK=REPLICATE("X",LEN(班级))

(2)查询里面COMMANDGROUP1.COMMAND1.CLICK()
cExprL=".T."
IF !EMPTY(THISFORM.TEXT1.VALUE)
cExprL=cExprL+".AND.BH='"+THISFORM.TEXT1.VALUE+"'"
ENDIF
*.....其余的类推
SELECT DA
SET FILTER TO &cExprL
GO TOP
THISFORM.REFRESH

感言:学以致用。 博客:http://www./blog/user14/65009/index.shtml email:Tiger5392@
2006-08-17 01:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-84419-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.051563 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved