Next / Previous Record

  • Thread starter Simon Glencross
  • Start date
S

Simon Glencross

I have a macro which when clicked goes to the next record, but when it gets
to the end of the records I get the following message

" You cant go to the specified record"
You may be at the end of the record set.

Which is correct but how do I stop this from appearing?

If I then click OK I then get an action failed message which obviously I do
not want my user to see.

I have tried the setwarnings to NO but this did not work.

Any suggestions gratefully recieved!

S
 
D

Douglas J. Steele

That's one of the liabilities of macros: they don't allow for error checking
(apparently this is somewhat remedied in Access 2007)

Before moving to the next record, you need to check whether the recordset is
already at the end of file (its EOF property will be True if is is). Since I
never use macros, I'm not sure whether macros give you the ability to check
the recordset's EOF property.
 
S

Simon Glencross

Doug,

Could you suggest an alternative way such as VB instead of a macro to move
to the next record and previous record without recieving such messages?

Thanks in advance

S
 
M

Marshall Barton

Simon said:
I have a macro which when clicked goes to the next record, but when it gets
to the end of the records I get the following message

" You cant go to the specified record"
You may be at the end of the record set.

Which is correct but how do I stop this from appearing?

If I then click OK I then get an action failed message which obviously I do
not want my user to see.

I have tried the setwarnings to NO but this did not work.


There's an example at:
http://www.lebans.com/recnavbuttons.htm
 
G

Guest

Put this code in the Click event of the NextRecord button:

If Not Me.Recordset.EOF Then
Me.Recordset.MoveNext
Else
MsgBox "No Next Record"
End If

Use a similar test for Me.Recordset.BOF for the Previous button
 
S

Steve Schapel

Simon,

The way to do it in a macro is to put this in the Condition of the
GoToRecord action...
[CurrentRecord]<[RecordsetClone].[RecordCount]

Alternatively, you can put a macro on the Current event of the form,
with a SetValue action to disable your 'Next' command button, using the
condition...
[CurrentRecord]=[RecordsetClone].[RecordCount]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top