简单描述:一个TEXTBOX,一个BUTTON,一个GRID。代码写在BUTTON的CLICK里如下:
b=ALLTRIM(thisform.text1.value)
thisform.grid1.RecordSourceType= 0
thisform.grid1.RecordSource="&b"
thisform.Refresh
退出表单时若不用这些表了则关掉他们:在FORM的DESTROY里写上CLOSE TABLES ALL
t1=alltrim(thisform.text1.value) &&text1的类型要为字符型
m="表"+t1
sele * from &m into cursor "temp"
thisform.grid1.recordsource=“temp”
"查询"按钮的click代码:
if allt(thisform.text1.value)="1"
thisform.grid1.recordsource="表1"
thisform.refresh
else
if allt(thisform.text1.value)="2" && 之所以再用个if ,是避免text1=3或4等情况
thisform.grid1.recordsource="表2"
thisform.refresh
endif
endif
当然,用do case 也能实现:
do case
case allt(thisform.text1.value)="1"
thisform.grid1.recordsource="表1"
thisform.refresh
case allt(thisform.text1.value)="2"
thisform.grid1.recordsource="表2"
thisform.refresh
endcase