Loop to check records

  • Thread starter Thread starter Penstar
  • Start date Start date
P

Penstar

I have a recordset as follows

The user is able to manually go in enter amend new records.
On form close I need to check to find that each tee and teetime has a P1,
P2, P3 and P4 record, and if one is missing do message to get user to fix and
exit sub
I am self taught with VB, and have no idea about loops. I really need some
help with writing the code for this one.

eventid tee teetime Player
25 1 11:00 P1
25 1 11:00 P2
25 1 11:00 P3
25 1 11:00 P4
25 10 11:00 P1
25 10 11:00 P2
25 10 11:00 P3
25 10 11:00 P4
25 2 11:05 P1
25 2 11:05 P2
25 2 11:05 P3
25 2 11:05 P4
25 11 11:05 P1
25 11 11:05 P2
25 11 11:05 P3
25 11 11:05 P4
etc

Thanks
Penny
 
I have a recordset as follows

The user is able to manually go in enter amend new records.
On form close I need to check to find that each tee and teetime has a P1,
P2, P3 and P4 record, and if one is missing do message to get user to fix and
exit sub
I am self taught with VB, and have no idea about loops. I really need some
help with writing the code for this one.

eventid tee teetime Player
25 1 11:00 P1
25 1 11:00 P2
25 1 11:00 P3
25 1 11:00 P4
25 10 11:00 P1
25 10 11:00 P2
25 10 11:00 P3
25 10 11:00 P4
25 2 11:05 P1
25 2 11:05 P2
25 2 11:05 P3
25 2 11:05 P4
25 11 11:05 P1
25 11 11:05 P2
25 11 11:05 P3
25 11 11:05 P4
etc

Thanks
Penny

If you want to iterate through a recordset, the easiest construct is:

Dim rs as recordset

Set rs = CurrentDb.OpenRecordSet("tblMyTable")

Do until rs.eof
if rs("myfield") = some condition then...... etc.
rs.movenext
loop

rs.close
set rs = nothing

.... but looking at your problem, I would suggest capturing the form's
Before_Update event to process the logic you are trying to enforce.

HTH,
James
 
Thank you. That was the track I was heading down, and I got it working.

Much appreciated.

Penny
 
Back
Top