Solved

Run code on Next Record button

Posted on 2006-11-05
4
1,251 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
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

809 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