943,895 Members | Top Members by Rank

Ad:
Mar 25th, 2007
0

FlexGrid issue and error "Invalid Row value"....

Expand Post »
Hi,

I have used a Flex Grid control in displaying a set of records from the MS ACCESS database (back end) with the means of VB6 code (front end).

In my database i have 9 records and the flex grid control has been deisgned at design time with 7 rows.
I have full- compiled my code and seen that NO syntax errors exist.

ISSUE:
At runtime, when the grid control retrieves the 9 records from the db, an error is popped up: "Invalid Row Value".
I have tested and seen that if there are 7 records in db, then no errors occur. But, at runtime, if the records queried, exceed the no of rows in the grid control, designed at design time, then this error occurs. And even no vertical scrollbar appears.

----------------------------------------------------------------------
Visual Basic 6 code:
----------------------------------------------------------------------
''''For loop counters for each cell. ex: (0,0) -> (ROW, COL)
Dim dblRow_ISBN As Double, dblCol_ISBN As Double

'''''coding for the DATAGRID control to populate itself with records
'--------------------------------------------------------------
-------------------------------------------------------------
Call Connect_Database ''''database connection code

recset.Open "select ISBN, [Book Title], Author, CoAuthor1, CoAuthor2 " _
& "from " & strTable & " " _
& "order by " & field & ""
'-------------------------------------------------------------------

If (recset.RecordCount <> 0) Then
For dblRow_ISBN = 1 To recset.RecordCount
dblCol_ISBN = 0

grdISBN.Row = dblRow_ISBN 'ROW will be same for all the 5 columns

grdISBN.Col = dblCol_ISBN
grdISBN.Text = recset.Fields("ISBN")
grdISBN.Col = dblCol_ISBN + 1
grdISBN.Text = recset.Fields("Book Title")
grdISBN.Col = dblCol_ISBN + 2
grdISBN.Text = recset.Fields("Author")
grdISBN.Col = dblCol_ISBN + 3
grdISBN.Text = recset.Fields("CoAuthor1")
grdISBN.Col = dblCol_ISBN + 4
grdISBN.Text = recset.Fields("CoAuthor2")

recset.MoveNext
Next dblRow_ISBN
End If
dbconn.Close 'closes database connection

====================================================

Who can really help me on this ? His help will be definately appreciated.
Awaiting reply....
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
intellogo is offline Offline
21 posts
since Mar 2007
Mar 26th, 2007
0

Re: FlexGrid issue and error "Invalid Row value"....

I recommend using something other than the flexgrid. I use the listview all the time. Setup the listview like below and add items.

visualbasic Syntax (Toggle Plain Text)
  1. With lvList
  2. .View = lvwReport
  3. .FullRowSelect = True
  4. .HideColumnHeaders = False
  5. .HideSelection = False
  6.  
  7. .ColumnHeaders.Add 1, , "Col 1"
  8. .ColumnHeaders.Add 2, , "Col 2"
  9. .ColumnHeaders.Add 3, , "Col 3"
  10.  
  11. End With
  12.  
  13. Dim irows As Integer
  14.  
  15. For irows = 0 To 10
  16. lvList.ListItems.Add lvList.ListItems.Count + 1, , "Data: " & CStr(irows)
  17. lvList.ListItems(lvList.ListItems.Count).ListSubItems.Add 1, , "Sub data 1: " & CStr(irows)
  18. lvList.ListItems(lvList.ListItems.Count).ListSubItems.Add 2, , "Sub data 2: " & CStr(irows)
  19. Next
Reputation Points: 10
Solved Threads: 2
Newbie Poster
Sentax is offline Offline
18 posts
since Nov 2006
Mar 26th, 2007
0

Re: FlexGrid issue and error "Invalid Row value"....

Hi..buddy,

Thanks a lot for ur willingness to help out. And give me an extra edge with a control that i have never used: the ListView, even though I have marked this post as RESOLVED.
I will surely refer to ur advice in future, when i need to display records in a manner such as in a grid.


QUESTION:
=======
I did not understand 2 code lines. Could u pls explain their syntax/pattern for parametres from ur code snippet ??

************************************************************
lvList.ListItems.Add lvList.ListItems.Count + 1, , "Data: " & CStr(irows)
************************************************************

***********************************************************
lvList.ListItems(lvList.ListItems.Count).ListSubItems.Add 1, , "Sub data 1: " & CStr(irows)
***********************************************************

And why do u recommend the ListView , instead of the FLEX GRID ?
Becoz, as per after going thru ur code, i am seeing that the ListView cannot draw the vertical & horizontal lines like a grid control. Hence this can lead to visual ambiguity for the reader, when the list is heavily populated with database records.
And i feel that the code for the grid that i have stated is much more simple requiring lesser variety of properties, arguments & methods.
Infact one does not need to know any syntax to code the Grid control, just a logical visual sequence of steps. But in ur List View, i am having problems to understand the code, becoz i have to learn the new format of the properties & argument patterns used.

Please provide a more solid and really simple point to make someone shift from coding the grid to using the ListView in future....
I am not being rude. But lets make it really worthwile to move to another probably better control (fingers crossed)
Awaiting ur techies suggestions....


Click to Expand / Collapse  Quote originally posted by Sentax ...
I recommend using something other than the flexgrid. I use the listview all the time. Setup the listview like below and add items.

visualbasic Syntax (Toggle Plain Text)
  1. With lvList
  2. .View = lvwReport
  3. .FullRowSelect = True
  4. .HideColumnHeaders = False
  5. .HideSelection = False
  6.  
  7. .ColumnHeaders.Add 1, , "Col 1"
  8. .ColumnHeaders.Add 2, , "Col 2"
  9. .ColumnHeaders.Add 3, , "Col 3"
  10.  
  11. End With
  12.  
  13. Dim irows As Integer
  14.  
  15. For irows = 0 To 10
  16. lvList.ListItems.Add lvList.ListItems.Count + 1, , "Data: " & CStr(irows)
  17. lvList.ListItems(lvList.ListItems.Count).ListSubItems.Add 1, , "Sub data 1: " & CStr(irows)
  18. lvList.ListItems(lvList.ListItems.Count).ListSubItems.Add 2, , "Sub data 2: " & CStr(irows)
  19. Next
Reputation Points: 10
Solved Threads: 0
Newbie Poster
intellogo is offline Offline
21 posts
since Mar 2007
Mar 26th, 2007
0

Re: FlexGrid issue and error "Invalid Row value"....

visualbasic Syntax (Toggle Plain Text)
  1. '************************************************************
  2. lvList.ListItems.Add lvList.ListItems.Count + 1, , "Data: " & CStr(irows)
  3. '************************************************************
  4.  
  5. 'The "lvList.ListItems.Add" is adding another row to the listview.
  6. 'The first argument is the index to add the row. (I'm using the next row in the listview as my index)
  7. 'The second argument is optional and I never really use it anyways.
  8. 'The third is the first cell in that row that will hold "Data: " & Cstr(irows)
  9.  
  10. '***********************************************************
  11. lvList.ListItems(lvList.ListItems.Count).ListSubItems.Add 1, , "Sub data 1: " & CStr(irows)
  12. '***********************************************************
  13.  
  14. 'The "lvList.ListItems(lvList.ListItems.Count).ListSubItems.Add" adds subitems to the row we just made above. The "(lvList.ListItems.Count) just states to make the subitems in the very last row of the listview.
  15. 'The "ListSubItems.Add" adds the subitem
  16. 'The first argument is the index of the subitem. In the first one it is the 1st index (2nd column) and the second is the 2nd index (3rd column).
  17. 'The second argument is optional and i don't use that either.
  18. 'The third argument is the data to put in the subitem cell.

Why would you want to switch? Well the Listview has alot of functionality to it once you learn it. You can make it look alot better and modify the cell data and then even update a database based on the modification.

The suggestion is my opinion on using the Listview over the Flexgrid cause like you I use to use the Flexgrid until I ran across the ListView and I was like wow this control is great, I'm going to use this from now on.

So if you don't feel comfortable learning a new control then don't but I had to share my opinion. Which is only that, my opinion. I hope you enjoy using either.
Reputation Points: 10
Solved Threads: 2
Newbie Poster
Sentax is offline Offline
18 posts
since Nov 2006
Mar 26th, 2007
0

Re: FlexGrid issue and error "Invalid Row value"....

Sorry, I forgot to post that the ListView can get the grid lines by going to the properties and selecting "GridLines" and change the value to True. If you Right-Click on the control and click Properties you will see a slew of options. Go ahead and play around with them. Its the only way to learn.
Reputation Points: 10
Solved Threads: 2
Newbie Poster
Sentax is offline Offline
18 posts
since Nov 2006
Mar 27th, 2007
0

Re: FlexGrid issue and error "Invalid Row value"....

Thanks a lot for ur code and willingness to help.

I have now almost learnt ur newly anticipated ListView control....BRAVO!!
I have attached my newly learnt knowledge as a zip file. Please see it and tell me if i am on the right track with the listView control (5 KB).


But I still cannot understand this line, mainly the bracketed part only:

lvSubjects.ListItems(lvSubjects.ListItems.Count).ListSubItems.Add 1, , "QWE"

I know that the above line is used for referring to code details for the subdata item. Please give me a better concept of the bracketed part.

Do u also know the deployment stuff of Crystal Report 11, then i can tell u my new issue on that. Maybe u could solve it....
Awaiting ur response....
Attached Files
File Type: zip Project1.zip (5.0 KB, 46 views)
Last edited by intellogo; Mar 27th, 2007 at 5:32 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
intellogo is offline Offline
21 posts
since Mar 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB6 application and Cryatal Reports Professional Addition 9
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Visual basic Help please!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC