Resumen Problemas con elDbGrid no enlazado

Claro que existe errores en el dbgrid no enlazado, para solucionarlo tienes que
modificar el procedimiento grdDataGrid_UnboundReadData y GetRelativeBookmarks que es lo que causa el problema. El fragmento de código es el sgte:

CODIGO EXTRAIDO DEL EJEMPLO PARA ADDDATA, DELETEROW Y WRITEDATA

Private Sub grdDataGrid_UnboundAddData(ByVal RowBuf As RowBuffer, _
                                       NewRowBookmark As Variant)
Dim iCol As Integer

GridTotalRows = GridTotalRows + 1
ReDim Preserve ArrGrid(col - 1, GridTotalRows - 1)
NewRowBookmark = GridTotalRows - 1 'Establece el marcador a la śltima fila.

For iCol = 0 To UBound(ArrGrid, 1)
    If Not IsNull(RowBuf.Value(0, iCol)) Then
        ArrGrid(iCol, GridTotalRows - 1) = RowBuf.Value(0, iCol)
    Else
         ArrGrid(iCol, GridTotalRows - 1)= grdDataGrid.Columns(iCol).DefaultValue
    End If
Next iCol

End Sub

Private Sub grdDataGrid_UnboundDeleteRow(Bookmark As Variant)
Dim iCol As Integer, iRow As Integer

For iRow = Bookmark + 1 To GridTotalRows - 1
    For iCol = 0 To NumberOfLines - 1
        ArrGrid(iCol, iRow - 1) = ArrGrid(iCol, iRow)
    Next iCol
Next iRow
GridTotalRows = GridTotalRows - 1
End Sub

Private Sub grdDataGrid_UnboundWriteData(ByVal RowBuf As RowBuffer,
WriteLocation As Variant)
Dim iCol As Integer
For iCol = 0 To NumberOfLines - 1
    If Not IsNull(RowBuf.Value(0, iCol)) Then
        ArrGrid(iCol, WriteLocation) = RowBuf.Value(0, iCol)
    End If
Next iCol
End Sub

CODIGO MODIFICADO PARA UNDBOUND READDATA Y GETRELATIVEBOOKMARK:

'***************************************************************
Private Sub grdDataGrid_UnboundReadData(ByVal RowBuf As RowBuffer,
StartLocation As Variant, ByVal ReadPriorRows As Boolean)
    Dim Bookmark As Variant
    Dim i As Long, RelPos As Long
    Dim J As Integer, RowsFetched As Integer
    Bookmark = StartLocation
    If ReadPriorRows Then
        RelPos = -1
    Else
        RelPos = 1
    End If
    RowsFetched = 0
    For i = 0 To RowBuf.RowCount - 1
        Bookmark = GetRelativeBookmark(GridTotalRows, Bookmark, RelPos)
        If IsNull(Bookmark) Then Exit For
       For J = 0 To RowBuf.ColumnCount - 1
         RowBuf.Value(i, J) = GetUserData(NumberCols, GridTotalRows,ArrGrid,
Bookmark, J)
        Next J
        RowBuf.Bookmark(i) = Bookmark
        RowsFetched = RowsFetched + 1
    Next i
    RowBuf.RowCount = RowsFetched

End Sub

Private Sub grdDataGrid_UnboundGetRelativeBookmark(StartLocation As
Variant, ByVal Offset As Long, NewLocation As Variant, ApproximatePosition
As Long)
    Dim Index As Long
    If IsNull(StartLocation) Then
        If Offset < 0 Then
            Index = GridTotalRows + Offset
        Else
            Index = -1 + Offset
        End If
    Else
        Index = Val(StartLocation) + Offset
    End If
    If Index >= 0 And Index < GridTotalRows Then
       ApproximatePosition = Index
       NewLocation = MakeBookmark(Index)
    Else
       NewLocation = Null
    End If

End Sub

LOS PROCEDIMIENTOS SON:

Public Function GetUserData(ByVal MAXCOL, ByVal NUMFILA&, ARR() As
String, Bookmark As Variant, Col As Integer) As Variant
    Dim Index As Long
    Index = IndexFromBookmark(NUMFILA, Bookmark, False)
    If Index < 0 Or Index >= NUMFILA Or Col < 0 Or Col >= MAXCOL Then
        GetUserData = Null
    Else
      GetUserData = ARR(Col, Index)
    End If
End Function

Public Function GetRelativeBookmark(ByVal NUMFILA&, Bookmark As
Variant, RelPos As Long) As Variant
    Dim Index As Long
    Index = IndexFromBookmark(NUMFILA, Bookmark, RelPos < 0) + RelPos
    If Index < 0 Or Index >= NUMFILA Then
        GetRelativeBookmark = Null
    Else
        GetRelativeBookmark = MakeBookmark(Index)
    End If
End Function

Public Function IndexFromBookmark(ByVal NUMFILA&, Bookmark As Variant,
ReadPriorRows As Boolean) As Long
    Dim Index As Long
    If IsNull(Bookmark) Then
        If ReadPriorRows Then
            IndexFromBookmark = NUMFILA
        Else
            IndexFromBookmark = -1
        End If
    Else
        Index = Val(Bookmark)
        If Index < 0 Or Index >= NUMFILA Then Index = -9999
        IndexFromBookmark = Index
    End If
End Function

Public Function MakeBookmark(Index As Long) As Variant
    MakeBookmark = str$(Index)
End Function

Dale una "ojeada" y adecualo a tus necesidades. Espero que te sirva , por si
acaso tengo el BV50 con SP3...



Resumen Resumen

Visual Basic Página de Visual Basic

Página principal Página principal

www.jrubi.com