?
Solved

Custom Navigation Buttons

Posted on 2008-11-01
11
Medium Priority
?
364 Views
Last Modified: 2012-06-21
I have implemented custom navigation buttons as seen below.

With MS Access's navigation buttons when the user tries to move records but the current record does not have all required fields filled runtime error 3314 is reported which my form traps. However, with my navigation buttons MS access does not call error 3314 instead it calls runtime error '2105': You can't go to the specified record. How can I get my navigation buttons to act the same as MS Access's?
Private Sub cmdMoveFirst_Click()
    On Error GoTo ErrorHandler
    DoCmd.GoToRecord , , acFirst
 
Exit Sub
 
ErrorHandler:
    MsgBox Err.Description
End Sub
 
Private Sub cmdMovePrevious_Click()
    On Error GoTo ErrorHandler
    DoCmd.GoToRecord , , acPrevious
 
Exit Sub
 
ErrorHandler:
    MsgBox Err.Description
End Sub
 
Private Sub cmdMoveNext_Click()
    On Error GoTo ErrorHandler
    DoCmd.GoToRecord , , acNext
 
Exit Sub
 
ErrorHandler:
    MsgBox Err.Description
End Sub
 
Private Sub cmdMoveLast_Click()
    On Error GoTo ErrorHandler
    DoCmd.GoToRecord , , acLast
 
Exit Sub
 
ErrorHandler:
    MsgBox Err.Description
End Sub
 
Private Sub cmdAddNew_Click()
    'On Error GoTo ErrorHandler
    DoCmd.GoToRecord , , acNewRec
    
    Err.Clear
    On Error GoTo 0
    UpdateTotalRecords
    
Exit Sub
 
ErrorHandler:
    MsgBox Err.Description
End Sub

Open in new window

0
Comment
Question by:bejhan
[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
  • 6
  • 5
11 Comments
 
LVL 75
ID: 22860262
Quick and Dirty:

Private Sub cmdMoveFirst_Click()
    On Error Resume Next                   ' ** do this on each button
    DoCmd.GoToRecord , , acFirst
    Err.Clear                                          ' ** do this on each button                            
End Sub

0
 
LVL 75
ID: 22860264
Also ... this is free and covers it:

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

mx
0
 
LVL 1

Author Comment

by:bejhan
ID: 22860290
Okay going to use those buttons, only problem is (if you open frmSampleRecordNavigation) then go to the end of the records and press next a new record is created (addnew). However, once you type something in for CusName the MS Access nav addnew becomes enabled while the custom nav addnew doesn't how can I fix this?
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 75
ID: 22860476
"and press next a new record is created (addnew)."

I don't think a new record is create *until* you actually type a character in a Bound field on the form.

mx
0
 
LVL 1

Author Comment

by:bejhan
ID: 22860482
Once you type something in the bound form then access records the record and its not just a blank one right, so after that you should be able to create a blank new one with the add new button (as you can with the access nav buttons) however, these custom buttons don't do this...
0
 
LVL 75
ID: 22860486
"while the custom nav addnew doesn't how can I fix this?"

It's working correctly.  Rec 65 (new rec position) ... you type a Cust Name ... the Add New is disabled as it should be. You can hit escape to Cancel the adding of the new record. However, the Add New btn is still grayed out *because* you are still at a new record position.

mx
0
 
LVL 1

Author Comment

by:bejhan
ID: 22860488
Right, but at this point MS Access will allow you to add a new record because it recognizes that this record isn't new anymore as you have placed data into it but the custom navigation does not allow you to do this because it does not recognize that you have completed this record.
0
 
LVL 75
ID: 22860617
Not exactly. If you Escape to cancel the rec, again, you are still a new Rec position - ready for a new record to be entered.  If you type a cust name, you will see the CustID appear ... say 115.  If you hit Esc ... and then do this again, you will now see the CustID is 116 ... and so it.  So in fact, it is working correctly.

ok ...I see what you are saying. What needs to happen is the AfterUpdate of the Form need to enable to New Rec button on the Nav Subform.

Add this code to frmSampleRecordNavigation's AfterUpdate event.

Private Sub Form_AfterUpdate()
    Me.SFfrmNavButtons.Form.cmdNew.Enabled = True
End Sub

mx
0
 
LVL 1

Author Comment

by:bejhan
ID: 22862835
I tried that already, afterupdate isn't called until you tab or enter at the last field of the record. I need something that is called as soon as a change is made (not saved)
0
 
LVL 1

Author Comment

by:bejhan
ID: 22862905
"The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database."

So shouldn't the afterupdate event be called as soon as the changed control loses focus?
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1000 total points
ID: 22863052
"So shouldn't the afterupdate event be called as soon as the changed control loses focus?"

Not fhe Form's AU ..

However ... You can use the On Dirty Event - which will change as soon as any Bound control is changed.

mx
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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