GotoRecord problem

Bruce75

Psychologist
Local time
Today, 19:56
Joined
Sep 29, 2004
Messages
46
Hi

I know this problem has been posted by others in this forum, but I can't seem to get the solutions working. I have a button on a form that triggers a gotorecord acnext code. When it gets to the end of the recordset, I would like the user to be brought back to the first record.

I have tried this (among many other things):

Private Sub postpone_Click()

Dim rs As Object
Set rs = Me.RecordsetClone

If rs.EOF = False Then
DoCmd.GoToRecord acDataForm, "frm_aftermdm", acNext
Else
DoCmd.GoToRecord acDataForm, "frm_aftermdm", acFirst
End If
rs.close
Set rs = Nothing


End Sub

It just continually runs the acNext rather than the acFirst line. I figure it must be because the rs.EOF never becomes true. What am I missing here? any help greatly appreciated.

thanks

Bruce
 
Have you single stepped the code to see what is happening?
 
after much searching I reckon it is because the eof only becomes true after the last record has been passed. So I have tried this instead:

Private Sub postpone_Click()

Dim rstc As Recordset
Set rstc = Me.RecordsetClone


rstc.MoveNext
If rstc.EOF Then
Set rstc = Nothing
DoCmd.GoToRecord , , acFirst
Exit Sub
Else
DoCmd.GoToRecord , , acNext
End If


End Sub

I now get a 'invalid reference to recordsetclone property. I am having no luck figuring out why this invalid.

As for single stepping through, I am beginner so I assume you mean checking each line one by one. In which case, I have done this, and the problem resides in the EOF not changing.

Again, as always, any help greatly appreciated.

Cheers

Bruce
 
As for single stepping through, I am beginner so I assume you mean checking each line one by one. In which case, I have done this, and the problem resides in the EOF not changing.
You put a breakpoint in the code and use the debugger F8 to single step the code and then you can hover the cursor over variables to see what they contain. See if Stephan Lebans' Nav Button code gives you some ideas.
 
thanks RG

Actually an earlier post by your good self seems to have moved me on a little. I used dim rstc as dao.recordset and this has got rid of the invalid reference error, now I get a 'no current record' error as I move through the records! still, a change is a good as a break.

cheers
 
Look at Stephan's code. Particularly the .CurrentRecord and .RecordCount.
 

Users who are viewing this thread

Back
Top Bottom