Solved

VB 6 Datagrid Control

Posted on 2006-07-24
8
292 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

747 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

14 Experts available now in Live!

Get 1:1 Help Now