Problem with Do Until

Lestatos

Registered User.
Local time
Yesterday, 20:53
Joined
Oct 22, 2013
Messages
16
Good evening dear programmers .
I have a problem for which I didn't find any information in Google .

Here is the problematic code :

Code:
With paymentid

Do Until employeeid.EOF = True
        .FindFirst .Fields("Emp_ID") = employeeid.Fields("Emp_ID")
     
If .NoMatch Then
        
        .AddNew
        .Fields("Emp_ID") = employeeid("Emp_ID")
        .Update
        
End If
employeeid.MoveNext
Loop



End With
The code is part of a public function . It (that part of code) should serve as a compare for the EMP_ID fields between two tables.
If in the first table ("Employees") - with recordset assosiated for it - employeeid , are recirds which are not present in the second table ("Payments")
with recordsed assosiated for it - paymentid then the code will add the missing records in the second table .

Normaly the code runs well ( i checked it ) until the .FindFirst command . It doesnt execute the command , but exits the function an returns back to the calling form . It doesn't also give me any runtime errors or syntax errors , etc.... what do you think might be going on here ?
:banghead::banghead:
 
You should be doing this in a query really. If you are trying to add missing emp_id into the paymentid table you should do something like this

Insert into paymentid (Emp_id)
Select emp_id from employeeid where emp_id not in (Select emp_id from paymentid)

One statement will insert every missing emp_id in one go. Nice and quick as well!
 
Wow ! :) Thanks a lot . That was really the perfect solution for my problem !
Good luck and thank you again .
 

Users who are viewing this thread

Back
Top Bottom