Loop Not Looping

  • Thread starter Thread starter DS
  • Start date Start date
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
 
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
 
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
 
Back
Top