954,582 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

loop problem

I am using the code below to update the fields in a table.bt it update only first recorde ..where m i doin wrong plzz. help me..!

StChk.Open "SELECT * From SPINF WHERE STATUS='Active'", Con, adOpenDynamic, adLockOptimistic
FeeTrans.Open "select * from TBLFEE ORDER BY VOUCHERNO", Con, adOpenDynamic, adLockOptimistic

Do While Not StChk.EOF

    FeeTrans.MoveFirst
    'StChk.MoveFirst

    If FeeTrans.Fields(2) = StChk.Fields(0) And FeeTrans.Fields(3) = StChk.Fields(45) Then
       
        StChk.Fields(39) = FeeTrans.Fields(26)
        FeeTrans.Fields(26) = 0
        FeeTrans.Fields(23) = True
        MsgBox ("Rc updated")
        FeeTrans.Update
        StChk.Update

    End If
      
      StChk.MoveNext
      FeeTrans.MoveNext
      
  Loop
  
  MsgBox ("All Records Has Transfered & Saved in new Receipts")

StChk.Close
FeeTrans.Close
SkyVValker
Light Poster
28 posts since Jan 2009
Reputation Points: 14
Solved Threads: 0
 
FeeTrans.MoveFirst 'StChk.MoveFirst

It seems you keep on moving back to the first record within a loop. Remove the part "movefirst", because you WANT it to go to the next record as per your code at the end.

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You