Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Duplicate rows in TDB8.0

Posted on 2004-04-02
4
Medium Priority
?
501 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 600 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

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

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…
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…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

618 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