Solved

Duplicate rows in TDB8.0

Posted on 2004-04-02
4
494 Views
Last Modified: 2007-12-19
Hi experts,

I am using TDBGrid 8.0 and VB6.
My grid is unbound, using an XArrayDB.

When a new row (row1) gets save/updated (when then user click on another row, the addnew row, row2)
The row1 gets duplicated on the grid (NOT in the database). The record appears twice on the grid (on the row1 as it should, AND on the first row, the one on top of all rows).

Does anybody has an idea why ?
Thanks

gallia
0
Comment
Question by:Gallia
[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
  • 2
  • 2
4 Comments
 
LVL 39

Expert Comment

by:appari
ID: 10745211

can you post the code related to where you are initializing the xarray (xarray.redim) and filling with initial data etc.
0
 

Author Comment

by:Gallia
ID: 10765696
Hi appari,

Sorry for the delay, I was away. Here is the code.

    Set objArray = New XArrayDB

    If o_rsData.EOF Then
        objArray.ReDim 0, 0, 0, 0
        o_objGrid.SetNbColumn 0
        'Bind the XArrayDB structure with Grid
        Set o_objGrid.Grid.Array = objArray
        Set o_rsData = Nothing
        Exit Sub
    Else
        objArray.ReDim 0, o_rsData.RecordCount - 1, 0, o_rsData.Fields.Count - 1
        o_objGrid.SetNbColumn o_rsData.Fields.Count
    End If

    'Display titles on column header
    With o_objGrid.Grid.Columns
        For i = LBound(i_vListInfo) To UBound(i_vListInfo)
            .Item(i).ValueItems.Presentation = i_vListInfo(i).Presentation
            If i_vListInfo(i).CaptionID <> 0 Then
                .Item(i).Caption = LoadResString(i_vListInfo(i).CaptionID)
            Else
                .Item(i).Caption = i_vListInfo(i).SystemName
            End If
            .Item(i).Tag = i
            .Item(i).Locked = i_vListInfo(i).Locked
            .Item(i).Width = i_vListInfo(i).DefaultWidth
            If i_vListInfo(i).Format = "" Then
                o_objGrid.SetColFormatADO i, i_vListInfo(i).DataType
            Else
                o_objGrid.SetColFormat i, i_vListInfo(i).Format
                o_objGrid.SetColAlignment i, i_vListInfo(i).Alignment
            End If
            .Item(i).Visible = i_vListInfo(i).Visible
        Next i
    End With

    If Not o_rsData.EOF Then
        'Populate XArrayDB structure
        i = 0
        With o_rsData
            While Not .EOF
                For j = 0 To objArray.Count(2) - 1
                    objArray(i, j) = .Fields(j).Value
                Next j

                .MoveNext
                i = i + 1
            Wend
        End With
    End If

    'Bind the XArrayDB structure with Grid
    Set o_objGrid.Grid.Array = objArray

    'Find the ADO data type of current column
    eADODataType = adVarChar

    o_objGrid.SetColAlignment 0, vbCenter
    o_objGrid.ApplyFormat

    Enabled = True
0
 
LVL 39

Accepted Solution

by:
appari earned 150 total points
ID: 10765963
change this part

   If o_rsData.EOF Then
        objArray.ReDim 0, 0, 0, 0
        o_objGrid.SetNbColumn 0
        'Bind the XArrayDB structure with Grid
        Set o_objGrid.Grid.Array = objArray
        Set o_rsData = Nothing
        Exit Sub
    Else
        objArray.ReDim 0, o_rsData.RecordCount - 1, 0, o_rsData.Fields.Count - 1
        o_objGrid.SetNbColumn o_rsData.Fields.Count
    End If


to


   If o_rsData.EOF Then
        objArray.ReDim 0, -1, 0, o_rsData.Fields.Count - 1

        o_objGrid.SetNbColumn 0
        'Bind the XArrayDB structure with Grid
        Set o_objGrid.Grid.Array = objArray
        Set o_rsData = Nothing
        Exit Sub
    Else
        objArray.ReDim 0, o_rsData.RecordCount - 1, 0, o_rsData.Fields.Count - 1
        o_objGrid.SetNbColumn o_rsData.Fields.Count
    End If


when no data is found always set rows ubound to -1. columns to no of columns in the grid. its working fine on my m/c.

is SetNbColumn is your own method?

0
 

Author Comment

by:Gallia
ID: 10766301
Thanks it worked.

SetNbColumn is my own. It is used for all the grid (tdbg) in the application.

gallia
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
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…
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…

736 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