AshikHusein
Registered User.
- Local time
- Today, 15:19
- Joined
- Feb 7, 2003
- Messages
- 147
I am trying to use this code when a form opens. Essentially what the code should do is to stop at the record when a certain field("ccc") has no data in it.
The problem is that it does not stop at the first record with the above condition but goes on till the EOF and the gives me an error message. Can anyone tell me what is wrong with the code?
Private Sub Form_Open(Cancel As Integer)
Dim rec As Variant
Set db = CurrentDb
Set rec = Me.RecordsetClone
Do Until rec("ccc") = ""
rec.MoveNext
Loop
Me.Bookmark = rec.Bookmark
rec.Edit
rec("ccc") = "1"
rec.Update
rec.Close
End Sub
The problem is that it does not stop at the first record with the above condition but goes on till the EOF and the gives me an error message. Can anyone tell me what is wrong with the code?
Private Sub Form_Open(Cancel As Integer)
Dim rec As Variant
Set db = CurrentDb
Set rec = Me.RecordsetClone
Do Until rec("ccc") = ""
rec.MoveNext
Loop
Me.Bookmark = rec.Bookmark
rec.Edit
rec("ccc") = "1"
rec.Update
rec.Close
End Sub