>Thank you for reply.
>
>Yes you right, it is a data grid what I have now. I thought DBGrid and DataGrid is the same. I have never used it before.
>
>Any way, now I still have the same problem. Is there a way to loop thru the grid and read the values?
>
>Because unless user move the record pointer to the next record, the table will never get update.
I hate having users input data directly into datagrid. I normally add textboxes, listbox and others to allow user to enter data and when the user press save, I add it to the database and refresh the grid.
To loop through a grid, you can use this code:
Private Sub cmdSave_Click()
Dim intRow As Integer
Call GridGotoTop(grdImport)
With grdImport
For intRow = 0 To .ApproxCount - 1
msgbox .Columns(0).Value
On Error Resume Next
.Row = .Row + 1
On Error GoTo 0
Next intRow
End With
End Sub
Public Sub GridGotoTop(ByRef pgrdGrid As MSDataGridLib.DataGrid)
With pgrdGrid
If Not (.DataSource Is Nothing) Then
If .VisibleRows < .ApproxCount Then
On Error Resume Next
Do While True
.Scroll 0, -10
.FirstRow = 0
If Err.Number <> 0 Then Exit Do
Loop
On Error GoTo 0
End If
If .ApproxCount > 0 Then
.Col = 0
.Row = 0
End If
End If
End With
End Sub
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com