Click here to Skip to main content
13,147,376 members (28,255 online)
Rate this:
Please Sign up or sign in to vote.
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 "select date,invNo,Product,Rate,qty from sale where rs.fields(1)=txtinvno.text",conn
for i =rs.recordcount()
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.

Posted 18-Mar-13 19:02pm
MohamedHassanAli 7-Apr-13 4:20am
Hey Rajesh,

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

1 solution

Rate this: bad
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 "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)

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.
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
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
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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 8 Apr 2013
Copyright © CodeProject, 1999-2017
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