Hi, I'm trying to add new rows to a datagrid from values of textboxes, it works fine but when the rows of the grid are bigger than the visible size of it, it gives an error of "incorrect number of line", i think it has to do something with the bookmark but i'm not very sure, can someone help plz?
VB Code:
' Set new recordset to add the new row Set rsArray = New ADODB.Recordset With rsArray .Fields.Append "ID_MONTO_ADICIONAL", adInteger .Fields.Append "CONCEPTO_MONTO", adVarChar, 50 .Fields.Append "MONTO_ADICIONAL", adDouble .CursorType = adOpenStatic .LockType = adLockOptimistic .Open '--load all the records that were before Dim i As Integer For i = 0 To can_filas - 1 ' can_filas has already the number of rows before adding a new one Me.dgMontosAdic.RowBookmark (i) [B]'--Get a row of the grid, gives error here when i insert record 11, and the visible size of the grid is 10[/B] ' Add all rows that were before .AddNew ![ID_MONTO_ADICIONAL] = i + 1 ![CONCEPTO_MONTO] = Me.dgMontosAdic.Columns(1).Text ![MONTO_ADICIONAL] = Me.dgMontosAdic.Columns(2).Text Next '--Add the new record .AddNew ![ID_MONTO_ADICIONAL] = i + 1 ![CONCEPTO_MONTO] = txtConcepto.Text ![MONTO_ADICIONAL] = txtMonto.Text .Update ' update the number of rows can_filas = can_filas + 1 End With ' update the grid with the new recordset and the new row. Set Me.dgMontosAdic.DataSource = rsArray
i hope u understand me, and thanks in advance for help![]()




Reply With Quote