Solved

Custom Navigation Buttons

Posted on 2008-11-01
11
319 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
  • 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 - Access MVP) earned 250 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now