VB6中的Flexgrid数据显示问题 [英] Flexgrid data display problem in VB6

查看:336
本文介绍了VB6中的Flexgrid数据显示问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家

我有一张MS Access桌子促销,它有几行发票数据这样的





日期InvNO产品价格数量

01/04/12 001 abc 10 5

01/04/12 001 pqr 12 7

01/04/12 001 xyz 11 3

01/04/12 002 abc 10 5

01/04/12 002 pqr 12 7

01/04/12 003 xyz 11 3

01/04/12 003 abc 10 5

01/04/12 004 pqr 12 7

01/04/12 005 xyz 11 3





当我输入时,我想在flexgid1中显示invoce数据发票号在txtinvno



连接字符串后我写了这样的代码

set rs = new ADODB.Recordset

rs.open从销售地点选择日期,invNo,产品,价格,数量rs.fields(1)= txtinvno.text,conn

index = 1

for i = rs.recordcount()

flexgrid1。 textmatrix(index,0)= rs.fields(2)

flexgrid1.textmatrix(index,1)= rs.fields(3)

flexgrid1.textmatrix(index, 2)= rs.fields(4)

指数=指数+ 1

rs.movenext

next i



代码可以工作,但它只显示第一行的记录。我认为我给出的循环是不正确的。我不是程序员,但是最谦虚的请更正代码。



问候

Rajesh

Hi Experts
I have an MS Access table Sale, it has several rows of invoice data like this


Date InvNO Product Rate Qty
01/04/12 001 abc 10 5
01/04/12 001 pqr 12 7
01/04/12 001 xyz 11 3
01/04/12 002 abc 10 5
01/04/12 002 pqr 12 7
01/04/12 003 xyz 11 3
01/04/12 003 abc 10 5
01/04/12 004 pqr 12 7
01/04/12 005 xyz 11 3


I want to display the invoce data in a flexgid1 when i type the invoice no in txtinvno

after the connection string I wrote the code like this
set rs = New ADODB.Recordset
rs.open "select date,invNo,Product,Rate,qty from sale where rs.fields(1)=txtinvno.text",conn
index=1
for i =rs.recordcount()
flexgrid1.textmatrix(index,0)=rs.fields(2)
flexgrid1.textmatrix(index,1)=rs.fields(3)
flexgrid1.textmatrix(index,2)=rs.fields(4)
index=index+1
rs.movenext
next i

The code works but its show only records in first row only.I think the looping I given is incorrect.I am not a programmer but a hobbiest please correct the code.

Regards
Rajesh

推荐答案

这是一个解决您问题的片段



Here is a snippet to address your problem

flexGrid1.FormatString = "<Product |<    Rate |< Qty "
set rs = New ADODB.Recordset
rs.open "select date,invNo,Product,Rate,qty from sale where rs.fields(1)=txtinvno.text",conn
While Not rs.EOF
    flexGrid1.AddItem rs.fields(2) & Chr(9) & rs.fields(3) & Chr(9) & rs.fields(4)
    rs.movenext
Wend



让我知道它是否有效。

几点观察


Let me know if it works.
Few points observed

for i=rs.recordcount()



在语法上不正确。我很想知道它是如何工作的。你可以随时使用调试器和立即窗口来查找这些功能问题。


is not syntactically correct. I am curious to know how it works for you. You can always use debugger and Immediate window to find those functional issues.


这篇关于VB6中的Flexgrid数据显示问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆