Solved

VB 6 Datagrid Control

Posted on 2006-07-24
8
294 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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
 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to skip loop 6 56
using Access 8 68
vb6 connector to SQL Server 2 37
Spell Check in VB6 13 112
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

813 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