|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
MSFlexGrid correct row updated
Hy All!
I have following code in my MSFlexGrid, which does not update the row in the correct cell, but always in the cell of first row. In the MSFlexgrid I can type and change the value without any problem, but once saved the grid (and the recordset too) show me updated the value of the correct column, but whatever row has been changed in typing, the new value appears always in the first row (correct column, but wrong row). This is in form load(): ----------------------- Dim rs As Recordset With rs .MoveLast MSFlexGrid4.Rows = .RecordCount MSFlexGrid4.Cols = 3 MSFlexGrid4.FixedCols = 0 .MoveFirst Do MSFlexGrid4.TextMatrix(.AbsolutePosition + 1, 1) = !Item MSFlexGrid4.TextMatrix(.AbsolutePosition + 1, 2) = !charge .MoveNext Loop Until .EOF End With And this is the command to save the changes ------------------------------------------------------ If Not txtDataEntry.Visible Then Exit Sub If txtDataEntry.Text <> MSFlexGrid4.TextMatrix(MSFlexGrid4.Row, _ MSFlexGrid4.col) Then cmdSave.Enabled = True End If MSFlexGrid4.TextMatrix(MSFlexGrid4.Row, MSFlexGrid4.col) = _ txtDataEntry.Text txtDataEntry.Visible = False With rs.Recordset .Edit !charge = txtDataEntry.Text !Item = txtDataEntry.Text .Update End With Anyone can help me to rebuild this code and have the recordset updated in the correct row instead constantly in row(1) ? Thanks in advance. |
|
#2
|
|||
|
|||
|
May be this helps....
Do U Have FixRow? I assume that U have 1 FixedRow because U want the first record to be at row 1: MSFlexGrid4.TextMatrix(.AbsolutePosition + 1, 1) = !Item Code:
This is in form load(): ----------------------- Dim i As Integer Dim rs As Recordset 'Where is rs set to the recordset? With rs .MoveLast MSFlexGrid4.Rows = .RecordCount + 1 MSFlexGrid4.Cols = 3 MSFlexGrid4.FixedCols = 0 .MoveFirst For i = 1 To MSFlexGrid4.Rows -1 'Its good to set Col 0 to the AbsolutePosition of rs MSFlexGrid4.TextMatrix(i, 0) = .AbsolutePosition MSFlexGrid4.TextMatrix(i, 1) = !Item MSFlexGrid4.TextMatrix(i, 2) = !charge .MoveNext Next i End With And this is the command to save the changes ------------------------------------------------------ If Not txtDataEntry.Visible Then Exit Sub If txtDataEntry.Text <> MSFlexGrid4.TextMatrix(MSFlexGrid4.Row, _ MSFlexGrid4.col) Then cmdSave.Enabled = True End If MSFlexGrid4.TextMatrix(MSFlexGrid4.Row, MSFlexGrid4.col) = _ txtDataEntry.Text txtDataEntry.Visible = False With rs.Recordset .AbsolutePosition = MSFlexGrid4.TextMatrix(MSFlexGrid4.Row, 0) .Edit !charge = txtDataEntry.Text !Item = txtDataEntry.Text .Update End With
__________________
I May Have Misinterpret U'r Post Correct Me If I Am Wrong......// Enjoy Coding........................../// zak2zak |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > MSFlexGrid correct row updated |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|