Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

invalid row number

Posted on 2014-08-04
3
Medium Priority
?
260 Views
Last Modified: 2014-08-11
when executing the following code, I get an error from the datagrid:

            esql2 = "select * from tblOrgMonthlyFunds where Inkind = 0"
            rec2.Open (esql2), conn, adOpenDynamic, adLockOptimistic
            rec2.AddNew
                      
            rec2!MonthlyID = MonthlyID
            rec2!AgencyID = AgencyID
            rec2!Program = Combo1
            rec2!Description = Text2
            rec2!Inkind = 0
            rec2!GrossAmount = Text3
            rec2!NetAmount = Text4
            rec2!InKindAmount = 0
            
            Set OrgMR2.DataGrid2.DataSource = rec2
            
            DataGrid2.Columns(0).Width = 0
            DataGrid2.Columns(1).Width = 0
            DataGrid2.Columns(2).Width = 0
            DataGrid2.Columns(8).Width = 0


            rec2.Update
            
         
Text2 = ""
Text3 = ""
Text4 = ""
          

SumTotal = 0
For i = 0 To DataGrid2.ApproxCount - 1
SumTotal = SumTotal + DataGrid2.Columns(7).CellValue(DataGrid2.GetBookmark(i))
Next
NetTotal = SumTotal

SumTotal = 0
For i = 0 To DataGrid2.ApproxCount - 1
SumTotal = SumTotal + DataGrid2.Columns(6).CellValue(DataGrid2.GetBookmark(i))
Next
GrossTotal = SumTotal

Open in new window


The error is "invalid row number" and it occurs on line 32

Any ideas why this is happening?
0
Comment
Question by:al4629740
3 Comments
 
LVL 9

Expert Comment

by:p_sie
ID: 40240909
Did you check the value of DataGrid2.GetBookmark(i)) when executing?
I bet that's where teh solution will be
0
 

Author Comment

by:al4629740
ID: 40241028
i = 1. During the error.  I don't see where the error is
0
 
LVL 15

Accepted Solution

by:
eemit earned 2000 total points
ID: 40242492
- GetBookmark Method Returns a value containing a bookmark for a row relative to the current row in a DataGrid control.
DataGrid2.GetBookmark(1) - Returns bookmark of the row following current row.
- Furthermore getting the ApproxCount property will query the underlying data source.

Therefore it is better to iterate through underlying recordset.

Dim oRs As ADODB.Recordset
Set oRs = Me.DataGrid2.DataSource
...
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question