Bawn
Bawn

Reputation: 509

Problems deleting first record

When I try to delete the first record from a table of added records I get this error :

RUN-TIME ERROR '3021' NO CURRENT RECORD

This only happens when I try to delete the first record. When I try to delete the second or third my code works fine:

Me.Labour_subform.Form.Recordset.Delete 

Me.Labour_subform.Form.Recordset.MoveNext

This is my code for the on_click of a button. Dose anyone know how to correct this ?

Upvotes: 0

Views: 54

Answers (1)

Aharpe
Aharpe

Reputation: 112

I always check for EOF then move to the first record when I am dealing with recordsets.

If not Me.Labour_subform.Form.Recordset.EOF then
     Me.Labour_subform.Form.Recordset.MoveFirst
     'Then delete or do whatever
end if

Upvotes: 1

Related Questions