Solved

Run code on Next Record button

Posted on 2006-11-05
4
1,274 Views
Last Modified: 2008-01-09
I need to hook the Next and Previous buttons on the bottom of my form window to run VB code. Probably very easy but I cannot find any samples.

Regards
Peter
0
Comment
Question by:peakpeak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 17876222
There are no events for the navigation buttions that you can add code to.  The form's current event will fire with each record change, and may work for you.  If that is not an option, you would have to create custom navigation buttons, set the form's Record Navigation Buttons property to "No" (and maybe consider disabling the mouse wheel for record changes).
0
 
LVL 61

Expert Comment

by:mbizup
ID: 17876232
>If that is not an option...
A reason that the Current event might not be an option is that if fires AFTER the record has changed.  
0
 
LVL 61

Accepted Solution

by:
mbizup earned 125 total points
ID: 17876250
Btw, the command button wizard makes it very easy to createcustom navigation buttons.  Select the type of button you want (next, prev, etc) from the Record Navigation category, and the code for the button will be atomaticlly generated.  All that's left is for you to modify the button's click event with your code:

Private Sub cmdNextRecord_Click()
On Error GoTo Err_cmdNextRecord_Click

    '*** Add any code that needs to run before a record change
    '*** Here.

    DoCmd.GoToRecord , , acNext
Exit_cmdNextRecord_Click:
    Exit Sub
Err_cmdNextRecord_Click:
    MsgBox Err.Description
    Resume Exit_cmdNextRecord_Click  
End Sub
0
 
LVL 61

Expert Comment

by:mbizup
ID: 17876543
Why the "B" grade?  My answer gave you everything you needed to accomplish this...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question