Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
MohamedHassanAli 7-Apr-13 4:20am    
Hey Rajesh,

Which Grid are you using?. MSFLEX or VSFlex grid.

1 solution

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
VB
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.
 
Share this answer
 
v2
Comments
Rajesh Kainikkara 29-Apr-13 8:32am    
Hi Mohamed
Thanks for the code, and sorry for my late reply. After I post the question I check it for a week regularly but unfortunately I didn't get a solution from here.Then I tried myself and solve it myself.Then I forgot to check it.Still I don't know much about VB but I am doing it somehow.I am expecting more help from you because still I have a lot of doubts in it.
Regards & Thanks
Rajesh
MohamedHassanAli 3-May-13 11:22am    
That's okay. You can try asking me your doubts I can do my best to get them answered.
Out of curiosity why do you prefer VB 6 ? Why not c ?
Rajesh Kainikkara 4-May-13 8:15am    
HiI am a Bcom holder in my regular work I am using Excel VBA so I have an idea about VB6,I don't know nothing about c. Moreover almost all business programs I see is made in VB6.That is the only reason.Now I post one more question in vb6 regarding key press event(keyascii 65 to 90) of ms flexgrid.Kindly check it and tell me how can solve it.
Regards & Thanks
Rajesh

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900