?
Solved

VB 6 Datagrid Control

Posted on 2006-07-24
8
Medium Priority
?
304 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 143

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 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
 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 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