Loop Not Looping

D

DS

The following code works fine...when theres a record.
If there is no record I get an error message...No Record.
How do I fix this so if theres no record in the PaymentSubform the form
still closes.
Thanks
DS

Private Sub Cancel_Click()
DoCmd.GoToControl "PaymentSubform"
With Forms!Payment.PaymentSubform.Form.RecordsetClone
.MoveFirst
Do While .EOF = False
.Delete
.MoveNext
Loop
End With

DoCmd.Close acForm, "Payment", acSaveNo
DoCmd.OpenForm "LogOn"
End Sub
 
D

Douglas J. Steele

With Forms!Payment.PaymentSubform.Form.RecordsetClone
If .BOF = False And .EOF = False Then
.MoveFirst
Do While .EOF = False
.Delete
.MoveNext
Loop
End If
End With
 
D

DS

Douglas said:
With Forms!Payment.PaymentSubform.Form.RecordsetClone
If .BOF = False And .EOF = False Then
.MoveFirst
Do While .EOF = False
.Delete
.MoveNext
Loop
End If
End With
Thanks That worked great...!
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top