Not Looping?

Status
Not open for further replies.

GavZ

Mostly Beginners Luck!
Local time
Today, 17:24
Joined
May 4, 2007
Messages
56
hi,

i have a continuous form where i am trying to get a loop statement working, i have tried simplifying it so that if the checkbox in the record is checked the write checked! in the textbox but it still not working!

Can anybody tell me why this isnt looping through the records?


Dim Rs As DAO.Recordset
Set Rs = CurrentDb.OpenRecordset("tfiles")

If Not Rs.EOF And Not Rs.BOF Then

Do Until Rs.EOF
If chbox_rec = True Then
tb_test.Value = "Checked!"
Endif
Rs.MoveNext
Loop
Rs.Close
End If

Set Rs = Nothing
 
Hi..:

Try this way..:


Dim Rs As Recordset
Set Rs = Form.Recordset

If Not Rs.EOF And Not Rs.BOF Then

Do Until Rs.EOF
If chbox_rec = True Then
tb_test = "Checked!"

End If
Rs.MoveNext
Loop

End If
 
Perfect thanks! - So simple!
 
Dim Rs As Recordset
It's best to be explicit so revert back to

Dim Rs As DAO.Recordset

Also, why are you looping through a recordset when you can do it quicker and in one go using an UPDATE query or statement :confused:
 
Because I was just testing the loop before I change it to call a separate function instead of just writing to a text box
 
In any case you can use call an UPDATE query to make the changes. Looping through a recordset is slower than doing it the SQL way.
 
Status
Not open for further replies.

Users who are viewing this thread

Back
Top Bottom