Hello friends,

I have a form that contains,

Item name------Combo box.
Msflex grid for Item name,qty.

If I select an item name from combo box,that name will be displayed in the
flexgrid first column Item name.Only I have to enter the qty.

If I enter 3 item names and qty like

Item name Qty

A 1
B 2
C 2

If I want to change the item from B to D,error comes.it shows "Enter qty"
It is not changing.How to clear the entire row details and enter a new item
My code:
VB Code:
  1. Private Sub cbomname_KeyPress(KeyAscii As Integer)
  2.     On Error Resume Next
  3.     If KeyAscii = 13 Then
  4.     If c <> 2 Then
  5.         If rec.State > 0 Then rec.Close
  6.         rec.open "select * from Materials where code='" & cbomname.Text & "'", conn
  7.                Text1.SetFocus
  8.         Text1.Text = cbomname.Text
  9.         c = c + 1
  10.         MSFlexGrid1.Col = MSFlexGrid1.Col + 1 Mod MSFlexGrid1.cols
  11.     Else: MsgBox "Error, Enter quantity.", vbExclamation, "Items"
  12. End If
  13. End If
  14. End Sub
  15.  
  16. Private Sub Text1_KeyPress(KeyAscii As Integer)
  17.     On Error Resume Next
  18.     If KeyAscii = 13 Then
  19. If c = 2 Then
  20.            
  21.                 r = r + 1
  22.                 MSFlexGrid1.rows = r
  23.                 MSFlexGrid1.Col = 0
  24.                 MSFlexGrid1.Row = i
  25.                 MSFlexGrid1.Col = MSFlexGrid1.Col + 1 Mod MSFlexGrid1.cols
  26.                 Text1.SetFocus
  27.                 MSFlexGrid1.TextMatrix(i + 1, Col) = r - 1
  28.                 c = 1
  29.                 i = i + 1
  30.                 MSFlexGrid1.Row = MSFlexGrid1.Row + 1 Mod MSFlexGrid1.rows
  31.                  cbomname.SetFocus
  32.             End If
  33.             q = i
  34.             q = q - 1
  35. end if