Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Microsoft: Access Forms FAQ

Form Basics

How to create your own Navigation without error messages by adamroof
Posted: 2 Jan 04

Just want to share this code for making your own navigation buttons that (1) dont go to a new record when you get to the end (2) doesnt give you error 'You cant go to the specified record' (3) Automatically recounts your form records on Form Filters and Queries. Obviously change the names where needed and you can still add your own Go To Last and Go To First buttons for full nav effect.

*** Create two textboxes, Text30 and Text33, create a label and make it say "Of" and place it between text30 and text33 on your form. I bolded text30 and text 33 ***

In Form Design, change Text30 Control Source to (=[Form].CurrentRecord)
Text33 is unbound, controlled by the On Current Event

*** Create On Current Event ***

Private Sub Form_Current()

    If Me.RecordsetClone.RecordCount > 0 Then        
        Me![Text33] = Me.RecordsetClone.RecordCount
        Exit Sub
    End If

End Sub

*** Create a button to go forward ***
*** Replace VBA Code Generated with below, changing names as needed ***

Private Sub ClientNextBtn_Click()
On Error GoTo Err_ClientNextBtn_Click

    If Text30 = Text33 Then
        Exit Sub
        DoCmd.GoToRecord , , acNext
    End If

    Exit Sub

    Resume Exit_ClientNextBtn_Click
End Sub

For the Previous button,

Private Sub ClientPrevBtn_Click()
On Error GoTo Err_ClientPrevBtn_Click

    DoCmd.GoToRecord , , acPrevious

    Exit Sub

    Resume Exit_ClientPrevBtn_Click
End Sub


The key to this is to include the error handler, but omit the MsgBox Err.Description that Access Auto Generates.

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close