Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB6
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 18-Mar-13 20:02pm
Comments
MohamedHassanAli at 7-Apr-13 4:20am
   
Hey Rajesh,
 
Which Grid are you using?. MSFLEX or VSFlex grid.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v2
Comments
Rajesh Kainikkara at 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 at 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 at 4-May-13 8:15am
   
Hi
I 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)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 230
2 BillWoodruff 205
3 Sergey Alexandrovich Kryukov 195
4 DamithSL 165
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,650
3 Kornfeld Eliyahu Peter 3,460
4 Sergey Alexandrovich Kryukov 2,811


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 8 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100