Solved

Duplicate rows in TDB8.0

Posted on 2004-04-02
4
491 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
  • 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

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

776 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