Solved

VB 6 Datagrid Control

Posted on 2006-07-24
8
293 Views
Last Modified: 2013-12-25
I am using datagrid control on my form and using following statement on button click.

AA = ""
    For i = 0 To DG2.ApproxCount - 1
    DG2.Row = i
    If CLng(DG2.Columns(4).Text) > 0 Then
        AA = AA + DG2.Columns(0).Text + "-" + " Code: " + DG2.Columns(1).Text + " Head: " + DG2.Columns(2).Text + " Amount: " + DG2.Columns(4).Text + ", "
        End If
    Next
AA = AA + TxtNaration.Text

It is working properly but in the last row it is showing following error:

RUN TIME ERRO '6148'
INVALID ROW NUMBER

Please help how to resolve this problem.

Rgds.
Mehram

0
Comment
Question by:Mehram
  • 5
  • 2
8 Comments
 

Author Comment

by:Mehram
ID: 17169590
Revised
--------

I am using datagrid control on my form and using following statement on button click.

AA = ""
    For i = 0 To DG2.ApproxCount - 1
    DG2.Row = i
    If CLng(DG2.Columns(4).Text) > 0 Then
        AA = AA + DG2.Columns(0).Text + "-" + " Code: " + DG2.Columns(1).Text + " Head: " + DG2.Columns(2).Text + " Amount: " + DG2.Columns(4).Text + ", "
        End If
    Next
AA = AA + TxtNaration.Text

It is working properly but in the last row it is showing following error:

Error Line ===>>>    DG2.Row = i
RUN TIME ERRO '6148'
INVALID ROW NUMBER

Please help how to resolve this problem.

Rgds.
Mehram
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17169629
please try this:

AA = ""
    For i = 0 To DG2.ApproxCount - 2
    DG2.Row = i
    If CLng(DG2.Columns(4).Text) > 0 Then
        AA = AA + DG2.Columns(0).Text + "-" + " Code: " + DG2.Columns(1).Text + " Head: " + DG2.Columns(2).Text + " Amount: " + DG2.Columns(4).Text + ", "
        End If
    Next
AA = AA + TxtNaration.Text
0
 

Author Comment

by:Mehram
ID: 17169681
Sir error is same.
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 17169773
Difficult to debug if one does not have vb :-(

For what value of i does it fail?

AA = ""
    For i = 1 To DG2.ApproxCount - 1
    DG2.Row = i
    If CLng(DG2.Columns(4).Text) > 0 Then
        AA = AA + DG2.Columns(0).Text + "-" + " Code: " + DG2.Columns(1).Text + " Head: " + DG2.Columns(2).Text + " Amount: " + DG2.Columns(4).Text + ", "
        End If
    Next
AA = AA + TxtNaration.Text
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Mehram
ID: 17170048
the total numbers of row is 69 and upon error move courser on dg its showing     dg.row = 9

0
 

Author Comment

by:Mehram
ID: 17170086
Is there any other way/logic to do this work
0
 

Author Comment

by:Mehram
ID: 17170293
Or is there any other control instead of datagrid which can use easly for the same purpose.
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 17187365
Is the datagrid bound to a recordset or data control?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

861 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now