Basic Coding Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am extremely new to VBA and am having a problem I hoped someone could help
me with. I am trying to refer to the current record on a form based on a
query. I am needing the current record to move to the next record after
updating a control and if it is already the last record on the form to go to
the first record. I have tried the following but keep getting an error.

Private Sub StartTime_AfterUpdate()
'Move the focus to the next record
rs.MoveNext
If rs.EOF Then
rs.MoveFirst
End If


End Sub

Please help.
 
Hi Kathy

It's not clear what (if anything!) rs is set to.

A better way to do this would be to use the form's RecordsetClone property:

With Me.RecordsetClone
.MoveNext
If .EOF Then .MoveFirst
Me.Bookmark = .Bookmark
End With
 
Thank you so much. That works perfectly.

Graham Mandeno said:
Hi Kathy

It's not clear what (if anything!) rs is set to.

A better way to do this would be to use the form's RecordsetClone property:

With Me.RecordsetClone
.MoveNext
If .EOF Then .MoveFirst
Me.Bookmark = .Bookmark
End With
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Kathy G said:
I am extremely new to VBA and am having a problem I hoped someone could
help
me with. I am trying to refer to the current record on a form based on a
query. I am needing the current record to move to the next record after
updating a control and if it is already the last record on the form to go
to
the first record. I have tried the following but keep getting an error.

Private Sub StartTime_AfterUpdate()
'Move the focus to the next record
rs.MoveNext
If rs.EOF Then
rs.MoveFirst
End If


End Sub

Please help.
 
Back
Top