PC Review


Reply
Thread Tools Rate Thread

eliminating the "You can't go to the specified record" error message

 
 
Paul James
Guest
Posts: n/a
 
      16th Sep 2004
I used the command button wizard to create Next Record and Previous Record
navigation buttons, but if you click on one of these buttons when you're in
the First or Last record, a useless error message appears saying "You can't
go to the specified record."

I'd like to trap this error so this doesn't happen. Can anyone tell me how
to do this?

Thanks in advance.

Paul


 
Reply With Quote
 
 
 
 
Fred Boer
Guest
Posts: n/a
 
      16th Sep 2004
Dear Paul:

You could use error handling and trap the error, either ignoring it or
popping up a message, but it would probably be better not to let the user
generate the error. What might be preferable is to disable the appropriate
navigation buttons when you are at the beginning or end of the recordset. I
have the following code in the Current event of my forms:

Me.RecordsetClone.MoveLast
Me.cmdGoNext.Enabled = Not (Me.CurrentRecord =
Me.RecordsetClone.RecordCount)
Me.cmdGoPrevious.Enabled = Not (Me.CurrentRecord = 1)

The first line ensures that Access has all of the records loaded, the next
two will enable/disable the navigation buttons to avoid the error message.
When you are on the first record, the Previous Record button will be grayed
out and disabled, and when you are on the last record the Next Record button
will be disabled and greyed out.

I have seen lots of variations in code to accomplish this - someone might
suggest something better...

Alternatively, you might consider letting an Access Expert do the heavy
lifting: check out the following by Stephen Lebans:

http://www.lebans.com/recnavbuttons.htm

It's a complete solution that you can just drop into your forms...

HTH
Fred Boer



"Paul James" <(E-Mail Removed)> wrote in message
news:eH%(E-Mail Removed)...
> I used the command button wizard to create Next Record and Previous Record
> navigation buttons, but if you click on one of these buttons when you're

in
> the First or Last record, a useless error message appears saying "You

can't
> go to the specified record."
>
> I'd like to trap this error so this doesn't happen. Can anyone tell me

how
> to do this?
>
> Thanks in advance.
>
> Paul
>
>



 
Reply With Quote
 
 
 
 
Paul James
Guest
Posts: n/a
 
      16th Sep 2004
Great. Thanks, Fred.


 
Reply With Quote
 
=?Utf-8?B?UnlhbiBX?=
Guest
Posts: n/a
 
      15th Jan 2005
Fred,
This code works great and thank you for posting it. What if the user wants
to add another record? With the code that is posted, I can only move to the
next record, I can not add any more. Any suggestions? Thank you so very much,
Ryan

"Fred Boer" wrote:

> Dear Paul:
>
> You could use error handling and trap the error, either ignoring it or
> popping up a message, but it would probably be better not to let the user
> generate the error. What might be preferable is to disable the appropriate
> navigation buttons when you are at the beginning or end of the recordset. I
> have the following code in the Current event of my forms:
>
> Me.RecordsetClone.MoveLast
> Me.cmdGoNext.Enabled = Not (Me.CurrentRecord =
> Me.RecordsetClone.RecordCount)
> Me.cmdGoPrevious.Enabled = Not (Me.CurrentRecord = 1)
>
> The first line ensures that Access has all of the records loaded, the next
> two will enable/disable the navigation buttons to avoid the error message.
> When you are on the first record, the Previous Record button will be grayed
> out and disabled, and when you are on the last record the Next Record button
> will be disabled and greyed out.
>
> I have seen lots of variations in code to accomplish this - someone might
> suggest something better...
>
> Alternatively, you might consider letting an Access Expert do the heavy
> lifting: check out the following by Stephen Lebans:
>
> http://www.lebans.com/recnavbuttons.htm
>
> It's a complete solution that you can just drop into your forms...
>
> HTH
> Fred Boer
>
>
>
> "Paul James" <(E-Mail Removed)> wrote in message
> news:eH%(E-Mail Removed)...
> > I used the command button wizard to create Next Record and Previous Record
> > navigation buttons, but if you click on one of these buttons when you're

> in
> > the First or Last record, a useless error message appears saying "You

> can't
> > go to the specified record."
> >
> > I'd like to trap this error so this doesn't happen. Can anyone tell me

> how
> > to do this?
> >
> > Thanks in advance.
> >
> > Paul
> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If my System.IO.StreamWriter Write method throws "The specified network name is no longer available." and I try to Dispose or Close it in the finaly clause the close or dispose method just throws "The specified network name is no longe Daniel Microsoft Dot NET Framework 1 8th Sep 2005 04:11 AM
"CD Audio Error 26: The specified parameter is out of range for the specified command." scharf.steven@gmail.com Windows XP General 0 18th Jul 2005 10:42 PM
Re: how to access Specified cell in a Specified date? John Vinson Microsoft Access 0 20th Sep 2004 05:38 PM
how to access Specified cell in a Specified date? =?Utf-8?B?YW1yenp6eno=?= Microsoft Access 0 20th Sep 2004 04:17 PM
Re: Delete Query cannot delete specified from specified tables... Nikos Yannacopoulos Microsoft Access 0 8th Jul 2004 01:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:13 AM.