Let me indent your code for you:
> Set dbs = CurrentDb()
>
> Set rst = dbs.OpenRecordset("SELECT * FROM tblinvoices ORDER BY telnr", dbOpenDynaset)
> Set rst1 = dbs.OpenRecordset("SELECT * FROM tbltelephonelines ORDER BY telnr", dbOpenDynaset)
>
> Do
> While Not rst1.EOF
> If rst!telnr = rst1!telnr Then
> rst.MoveNext
> rst1.MoveNext
> Wend
> ElseIf rst!telnr <> rst1!telnr Then
> MsgBox (rst!telnr & " " & "cannot be found in the database")
> rst.MoveNext
?!
> Loop Until rst.EOF
> End if
You cannot nest tests/loops like this. Draw the structure of the code
for yourself in a diagram or so, and code again.
--
Bas Cost Budde
|