Hi
This is the code that I write to update database sql. When user type a
number in text1.text press enter, he will open TABEL1 and check record
from first to last to chech field(0), if exist text2 get value field(1)
and value in field(1) is deduted by 1 and update to the TABEL1

The fact here when runtime, every record in the TABEL1 are deducted when
number exist;text1.text=field(0)

When I use change the connectionstring and connect to Acces tabel, it
run smoothly;only 1 record is updated.

If any one could give an idea of how it would work be greatly appreciated
and thanks a lot
VB Code:
  1. Private Sub Text1_KeyPress(KeyAscii As Integer)
  2.  
  3. If KeyAscii = 13 Then
  4.     Label3.Visible = False
  5.     On Error GoTo errhandler 'on error resume next
  6.     Set objConnection = New ADODB.Connection
  7.     objConnection.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=adodata;Data Source=pc14;"
  8.     objConnection.CursorLocation = adUseClient
  9.     objConnection.Open
  10.     Set objRS = New ADODB.Recordset
  11.  
  12. objRS.Open "SELECT * FROM TABLE1", objConnection, adOpenDynamic, adLockOptimistic
  13.    
  14.     objRS.MoveFirst
  15.     Do While Not objRS.EOF
  16.         If Text1.Text = objRS.Fields(0) Then
  17.            
  18.             Text2.Text = objRS.Fields(1)
  19.             If Text2.Text <= 1 Then
  20.                 Text1.Text = ""
  21.                 Text2.Text = ""
  22.                 objConnection.Close
  23.                 Label3.Caption = "Sorry! Code expired"
  24.                 Label3.Visible = True
  25.                 Exit Sub
  26.             Else
  27.                 lngSetTop = SetTopMost(hWnd, False)
  28.                 Timer1.Enabled = True
  29.                 objRS.Fields(1) = objRS.Fields(1) - 1
  30.                 objRS.Update
  31.                 DisableCtrlAltDelete (True)
  32.                 Form1.Show
  33.                 AdoDao.Visible = False
  34.                 Exit Do
  35.             End If
  36.        
  37.         End If
  38.         objRS.MoveNext
  39.         Loop
  40.      
  41. End If
  42. errhandler:
  43. If Err.Number = 2147467259 Then
  44.     objConnection.Close
  45.     AdoDao.Show
  46.         Label3.Caption = "Server fail"
  47.         Label3.Visible = True
  48.   Exit Sub
  49. End If
  50. End Sub