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

Discussion in 'Microsoft Access Form Coding' started by Paul James, Sep 16, 2004.

  1. Paul James

    Paul James Guest

    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
     
    Paul James, Sep 16, 2004
    #1
    1. Advertisements

  2. Paul James

    Fred Boer Guest

    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" <> wrote in message
    news:eH%...
    > 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
    >
    >
     
    Fred Boer, Sep 16, 2004
    #2
    1. Advertisements

  3. Paul James

    Paul James Guest

    Great. Thanks, Fred.
     
    Paul James, Sep 16, 2004
    #3
  4. Paul James

    Guest Guest

    Re: eliminating the "You can't go to the specified record" error m

    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" <> wrote in message
    > news:eH%...
    > > 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
    > >
    > >

    >
    >
    >
     
    Guest, Jan 15, 2005
    #4
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ginger Day

    Error Message on Form save: You cant go to the specified record.

    Ginger Day, May 27, 2004, in forum: Microsoft Access Form Coding
    Replies:
    1
    Views:
    312
  2. Guest

    error 2105 you can't go to the specified record.

    Guest, Jun 22, 2005, in forum: Microsoft Access Form Coding
    Replies:
    0
    Views:
    446
    Guest
    Jun 22, 2005
  3. JeffMKlein

    Error Run time 2105 You cant go the the specified record

    JeffMKlein, Dec 1, 2005, in forum: Microsoft Access Form Coding
    Replies:
    6
    Views:
    1,499
    Guest
    Dec 14, 2005
  4. Guest

    "runtime error 2105" cant go to specified record

    Guest, Mar 3, 2006, in forum: Microsoft Access Form Coding
    Replies:
    1
    Views:
    446
    Guest
    Mar 3, 2006
  5. Larry Mehl
    Replies:
    1
    Views:
    360
    Allen Browne
    Dec 27, 2006
Loading...

Share This Page