472,127 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Controlling "Next record" button

Tim
I have used a graphic 'next record' button on a form. How can I stop it
from going past the last existing record? In other words, I don't want it
to take the user to a blank record.

Thanks
Tim
Nov 13 '05 #1
4 6567
You have to have some code for that button. Check in the code... the Form's
RecordsetClone is one source. If you can't determine how, clarify by posting
the code you are using and perhaps someone can make a more concrete
suggestion.

Larry Linson
Microsoft Access MVP
"Tim" <tg@neo.rr.com> wrote in message
news:GQ*******************@fe2.columbus.rr.com...
I have used a graphic 'next record' button on a form. How can I stop it
from going past the last existing record? In other words, I don't want it
to take the user to a blank record.

Thanks
Tim

Nov 13 '05 #2
In message <GQ*******************@fe2.columbus.rr.com>, Tim
<tg@neo.rr.com> writes
I have used a graphic 'next record' button on a form. How can I stop it
from going past the last existing record? In other words, I don't want it
to take the user to a blank record.


This code traps that specific error and beeps if the user attempts to go
beyond the last record. The code is in the On Click event handler for a
control called GoNext.

--------------8<--------------------------------------------------8<-----
--------

Private Sub GoNext_Click()
On Error GoTo Err_GoNext_Click
DoCmd.GoToRecord , , acNext

Exit_GoNext_Click:
Exit Sub

Err_GoNext_Click:
If Err = 2105 Then
Beep
Else
MsgBox (Str(Err) & " - " & Err.DESCRIPTION)
End If
Resume Exit_GoNext_Click
End Sub

--
Bernard Peek
London, UK. DBA, Manager, Trainer & Author. Will work for money.

Nov 13 '05 #3
Bernard,

Using this code, the button still takes me to a blank record at the end and
beeps.
Tim

"Bernard Peek" <ba*@shrdlu.com> wrote in message
news:Ih**************@shrdlu.com...
In message <GQ*******************@fe2.columbus.rr.com>, Tim
<tg@neo.rr.com> writes
I have used a graphic 'next record' button on a form. How can I stop it
from going past the last existing record? In other words, I don't want itto take the user to a blank record.


This code traps that specific error and beeps if the user attempts to go
beyond the last record. The code is in the On Click event handler for a
control called GoNext.

--------------8<--------------------------------------------------8<-----
--------

Private Sub GoNext_Click()
On Error GoTo Err_GoNext_Click
DoCmd.GoToRecord , , acNext

Exit_GoNext_Click:
Exit Sub

Err_GoNext_Click:
If Err = 2105 Then
Beep
Else
MsgBox (Str(Err) & " - " & Err.DESCRIPTION)
End If
Resume Exit_GoNext_Click
End Sub

--
Bernard Peek
London, UK. DBA, Manager, Trainer & Author. Will work for money.

Nov 13 '05 #4
In message <M7*******************@fe2.columbus.rr.com>, Tim Graichen
<Tg*******@neo.rr.com> writes
Bernard,

Using this code, the button still takes me to a blank record at the end and
beeps.
Tim


Sorry, it was only half the solution. Check the form properties and set
"Allow Additions" to no.
--
Bernard Peek
London, UK. DBA, Manager, Trainer & Author. Will work for money.

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by me | last post: by
reply views Thread by Alessandro | last post: by
4 posts views Thread by johnb41 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.